java.lang · java.base · since Java 1.2
Comparable
public interface Comparable<T>Natural ordering: compareTo returns negative/zero/positive. Implemented by String, numbers, dates — and by your value classes that have one obvious order (EJ 14).
Key methods
int compareTo(T o) | The contract: sgn(a.compareTo(b)) == -sgn(b.compareTo(a)); transitive; ideally consistent with equals. |