Difference between Comparable and Comparator

Comparable and Comparator are two Java interfaces that allow objects to be compared and sorted. Comparable Comparable is a functional interface that is implemented by a class to define its natural ordering. The compareTo method of the Comparable interface compares an object with another object and returns an integer indicating their relative order. class Person … Continue reading Difference between Comparable and Comparator