Comparable Interface in Java.

Java Comparable interface used to sort a array or list of objects based on their natural order. Natural ordering of elements is imposed by implementing it’s compareTo() method in the objects.This interface is found in java.lang package and contains only one method named compareTo(Object). This ordering is referred to as the class’s natural ordering, and the class’s compareTo() method is referred to as its natural comparison method.…

Read More