Comparable

The standard interface a type implements to define its natural ordering, through a compareTo method.

In more detail

compareTo returns a negative number, zero or a positive number when this value is less than, equal to or greater than the other. Sorting and generic methods bounded by Comparable rely on it.

Example

left.compareTo(right) >= 0 ? left : right

Related terms

Taught in

References