public interface Comparable<T> { public int compareTo(T o); } public final class Integer extends Number implements Comparable<Integer> { ... public static int compare(int x, int y) { return (x < y) ? -1 : ((x == y) ? 0 : 1); } ... public int compareTo(Integer anotherInteger) { return compare(this.value, anotherInteger.value); } ... } |