Comparable Comparator 1 this interface allows the object to compare itself with another object while sorting the list of such type objects. This interface provide the provision to compare two different objects. 2 The objects those implements Comparable interface are sorted automatically without specifying any other comparator. Comparator is passed as arguments to the method who need to sort some objects. 3 less flexible more flexible 4 uses compareTo (object2) method it has compare (object1,object2) method 5 this interface is not a part of collection API. It belongs to java.lang Packages this interface belongs to java.util package. Using Comparable package collection.examples; import java.util. ArrayList ; import java.util. Collections ; class Contact implements Comparable < Contact > { ...
Future driven solutions.