FileDocCategorySizeDatePackage
Comparable.javaAPI DocAndroid 1.5 API2390Wed May 06 22:41:04 BST 2009java.lang

Comparable

public interface Comparable
This interface should be implemented by all classes that wish to define a natural order of their instances. {@link java.util.Collections#sort} and {@code java.util.Arrays#sort} can then be used to automatically sort lists of classes that implement this interface.

The order rule must be both transitive (if {@code x.compareTo(y) < 0} and {@code y.compareTo(z) < 0}, then {@code x.compareTo(z) < 0} must hold) and invertible (the sign of the result of x.compareTo(y) must be equal to the negation of the sign of the result of y.compareTo(x) for all combinations of x and y).

In addition, it is recommended (but not required) that if and only if the result of x.compareTo(y) is zero, then the result of x.equals(y) should be {@code true}.

since
Android 1.0

Fields Summary
Constructors Summary
Methods Summary
public intcompareTo(T another)
Compares this object to the specified object to determine their relative order.

param
another the object to compare to this instance.
return
a negative integer if this instance is less than {@code another}; a positive integer if this instance is greater than {@code another}; 0 if this instance has the same order as {@code another}.
throws
ClassCastException if {@code another} cannot be converted into something comparable to {@code this} instance.
since
Android 1.0