Comparators in java

Comparator is a generic interface that has this declaration: Here, T specifies the type of objects being compared. The Comparator interface defines two methods: compare( ) and equals( ). The compare( ) method, shown here, compares two elements for order: int compare(T obj1, T obj2) obj1 and obj2 are the objects to be compared. This method returns zero if the … Read more