PPT Slide
Compares this object with the specified object for order.
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
The implementor must ensure
sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y.
(This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)
The implementor must also ensure that the relation is transitive: (x.compareTo(y)ɬ && y.compareTo(z)ɬ) implies x.compareTo(z)ɬ.
Finally, the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.