Explain the Java Collections Framework?

The key interfaces used by the collections framework are List, Set and Map. The List and Set extends the Collection interface. Should not confuse the Collection interface with the Collections class which is a utility class.

Set (HashSet , TreeSet) List (ArrayList, LinkedList, Vector etc)
A Set is a collection with unique elements and prevents duplication within the collection. HashSet and TreeSet are implementations of a Set interface. A TreeSet is an
ordered HashSet, which implements the SortedSet interface.
A List is a collection with an ordered sequence of elements and may contain duplicates. ArrayList, LinkedList and Vector are implementations of a List interface. (i.e. an index based)

The Collections API also supports maps, but within a hierarchy distinct from the Collection interface. A Map is an object that maps keys to values, where the list of keys is itself a collection object. A map can contain duplicate values, but the keys in a map must be distinct. HashMap, TreeMap and Hashtable are implementations of a Map interface. A TreeMap is an ordered HashMap, which implements the SortedMap interface.

Tagged . Bookmark the permalink.

Leave a Reply