Comparator Interface

• Comparator interface present in java.util package this interface defines the following 2 methods.
1) public int compare(Object obj1,Object Obj2);
2) public booleanequals(Objectobj);
• Whenever we are implementing Comparator interface we have to provide implementation only for compare() method.
• Implementing equals() method is optional because it is already available from Object class through inheritance.

Leave a Reply

Your email address will not be published. Required fields are marked *