News

Many of Java’s core classes implement Comparable. Use TreeMap or TreeSet when sorting a Map or a Set. The compareTo() method works with both Comparable and Comparator.
If you want to take advantage of sorting methods in Java, you'll need to implement the Comparable interface. Written by David Petersheim, Contributor Feb. 17, 2005 at 8:00 a.m. PT ...