Is there anything wrong with the above code?

Yes, 2 things — firstly, the above sort is case sensitive, that is the uppercase takes priority over lowercase pushing ‘Java’ after ‘JSP’. Secondly, if the collection had any null values, it will throw a NullpointerException. These two issues can be rectified by providing a custom sorting implementation that ignores case and handles null values … Read more

Can you write code to sort the following string values naturally (i.e. in alphabetical order)? (JEE, Java, Servlets, JMS, JNDI, JDBC, JSP, and EJB)

Here is the sample code that makes use of the default compareTo( ) provided in the String class as it implements the Comparable interface and the Collections utility class that provides a sorting method, which internally uses the efficient “merge sort” algorithm. import java.util.Arrays; import java.util.Collections; import java.util.List;   public class Sort1 { public static … Read more

Illustrate – domain or value object class to compare different object fields in an equals method

cmd/designated folder/ jar cf name.jar *.* Create a file: META-INF/MANIFEST.MF Add a line: Main-Class: com.myco.calc.CalculatorDemo Include META-INF/MANIFEST.MF in calculator.jar Run with java -jar calculator.jar This is useful in domain or value object class to compare different object fields in an equals method public class DomainObject {   //protected because only inheriting domain classes can use … Read more

How convert java file to jar files

cmd/designated folder/ jar cf name.jar *.* Create a file: META-INF/MANIFEST.MF Add a line: Main-Class: com.myco.calc.CalculatorDemo Include META-INF/MANIFEST.MF in calculator.jar Run with java -jar calculator.jar. To convert a Java file to a JAR (Java Archive) file in Advanced Java, you typically use the Java Archive (jar) tool provided by the Java Development Kit (JDK). Here are … Read more

What is stub?

Stubs are classes that provide replacement implementations for the actual classes client side component to send request to the server in RMI. In the context of advanced Java programming, a “stub” typically refers to a component used in remote method invocation (RMI). RMI is a mechanism that allows objects to invoke methods on objects running … Read more