Comparator interface is used to order the objects of user-defined classes. A comparator object is capable of comparing two objects of two different classes. Following function compare obj1 with obj2 Syntax: public int compare(Object obj1, Object obj2): Suppose we have an array/arraylist of our own class type, containing fields like rollno, name, address, DOB etc … Continue reading Comparator Interface and sorting in Java