Redirected from Collections API
The List interface enables the programmer to aggregate objects and then traverse the list, as when performing some operation on each of the list's members.
The Set interface enforces the rule that no two objects it contains are equal to each other. An OrderedSet (backed by a TreeSet) keeps the objects in order.
A Map maintains a one-to-one mapping of key to object -- handy for doing look-ups. For example, if you know a City, you can use a Map to find look up the corresponding Country.
Objects are kept in order by using a Comparator whose compareTo method defines a natural ordering of objects. Often the compareTo method is defined in the class definition of the objects themselves, rather than being in a separate Comparator object.
See: Java API
Search Encyclopedia
|
Featured Article
|