[Solved] compareTo method explain 1, -1, 0


By JavaDoc return from the method compareTo(obj) is:

a negative integer, zero, or a positive integer as this object is less
than, equal to, or greater than the specified object.

This mean that if you invoke method on current object this.compareTo(obj) and by your own logic in method compareTo this object grater than obj that you passed to method, return would be a positive integer.

Your own logic mean that, for example in object that you compare to other, exist some integer field and if this field greater than other field in other object, by your logic, you consider that this object greater than other.

solved compareTo method explain 1, -1, 0