hashcode() and equals() : Overview hashcode() and equals() methods are defined in java.lang.Object class which is the super class of all classes in java and hence may be overridden in any class. The signature of hashcode() method is public int hashCode() which means it should return an integer, and The signature of equals() method looks like public boolean equals(Object obj) which means it returns a boolean value indicating whether the object which called it is equal to the object which is passed as an argument to it or not.Read More →

Sort list of objects on a field Suppose you have a list which contains objects of your own class rather than java’s built in classes such as java.lang.Integer, java.lang.String etc. Now you want this list to be sorted on a particular field of this class. Let’s say we have a User class which contains user details such as name, age, address etc., and we have a list of various users. Now we want a list wherein users are listed in the order of their increasing age. That is, we need to sort the above list in the order of age. Collections.sort method You can sortRead More →