devxlogo

Understand the Main Interfaces of the Collections API

Understand the Main Interfaces of the Collections API

JDK 1.2 includes a new library of data structures called Collections. The Collections API contains object collection data structures. The Collection interface is the root interface for all the Collection classes. It basically represents a group of object called “elements.” If you want to store a collection of unique elements and do not care about the order in which they are stored, use a Set. To store a collection of unique ordered elements, use a SortedSet. To store a collection of ordered elements, (not necessarily unique), use a List. To store an unordered collection of elements that are retrievable by key, use a Map. Finally, to store an ordered collection of elements that are retrievable by key, use SortedMap. The following data structures of JDK 1.1 have been replaced in JDK 1.2: Vector is replaced with List, and Hashtable is replaced with Map.

devx-admin

Share the Post: