What is meant by natural ordering of objects in the context of the collections framework?
Location: http://www.jguru.com/faq/view.jsp?EID=219388 Created: Sep 29, 2000 Modified: 2005-09-12 13:58:13.706 Author: Avi Kak (http://www.jguru.com/guru/viewbio.jsp?EID=26410) Java documentation refers to the natural ordering of objects when describing various algorithms and data structures in the collections framework. Object ordering is obviously needed by the sorting algorithms. It is also needed by the specifications of the interfaces such as SortedSet, SortedMap, etc., and the data structures used for container classes such as TreeSet, TreeMap, etc. Unless instructed otherwise via a Comparator object supplied as an argument to the constructor, the default behavior of a class such as TreeSet is to store its objects in an ascending natural order. The objects of a class exhibit natural ordering if the class has implemented the java.lang.Comparable interface. Such a class must provide an implementation for the compareTo method — referred to as the class’s natural comparison method –