What is compareTo method?

The compareTo method compares the current object with the object sent as a parameter . When implementing it, we need to make sure that the method returns: A positive integer, if the current object is greater than the parameter object. A negative integer, if the current object is less than the parameter object.

Read more