1
JavaBeginner#jvm#fundamentals
compareTo() must be consistent, transitive, and (ideally) consistent with equals() — a.compareTo(b) should have the opposite sign of b.compareTo(a). Breaking this contract causes unpredictable behavior in sorted collections like TreeSet or TreeMap.
class BadPoint implements Comparable<BadPoint> {
int x;
public int compareTo(BadPoint o) { return x > o.x ? 1 : 0; } // broken: never returns negative, violates contract
}