[all packages]
[package java.lang]
[class hierarchy]
[index]
java.lang.Object | +----java.lang.Comparable<A>
public interface Comparable<A>
Arrays of Objects that implement this interface can be sorted automatically by List.sort. Objects of these classes can also be used as keys in TreeTables without the need to specify a Comparator.
Classes that implement this interface include String, Byte, Character, Short, Integer, Long, Float, Double, BigInteger, BigDecimal, File, URL, Date.
public abstract int compareTo(A o);
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)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.
The implementer must also ensure that x.equals(y) implies that x.compareTo(y)==0. Note that the converse is not necessarily true (e.g., BigDecimal).
Finally, the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.
Object
to be compared.
[all packages]
[package java.lang]
[class hierarchy]
[index]