Java provides a comparable interface that contains only one CompareTo () method. This method can be used to sort two objects in a single order. Specifically, it returns a negative number, 0, a positive number to indicate that an existing object is less than, equal to, greater than the input object.
Java provides a comparator interface that contains two methods of compare () and equals () .
The Compare () method is used to sort two input parameters , return a negative number, 0, and a positive number indicates that the first parameter is less than, equal to, greater than the second argument.
The Equals () method requires an object as a parameter that determines whether the input parameters are equal to comparator. This method returns true only if the input parameter is also a comparator and the input parameter is the same as the current comparator's ordering result.
The difference between the "Java" comparable and the comparator interface