Collection Framework

Collection Framework provides classes and interfaces that can be used to represent collections i.e. a group of objects.

Interfaces in the Collection Framework
Following are the interfaces provided by the Collection Framework :

1. Collection :
- defines the most common methods which are applicable for any Collection object.

2. List :
- Child interface of Collection.
- represents group of objects
- duplicates allowed
- order of insertion preserved
- Child classes : ArrayList, LinkedList, Vector->Stack

3. Set : 
- Child interface of Collection.
- represents group of objects
- unique elements i.e. duplicates not allowed
- insertion order not preserved
- Child classes : HashSet, LinkedHashSet

4. SortedSet :
- Child interface of Set
- represents group of objects
- unique elements i.e. duplicates not allowed
- elements stored in a sorted order

5. NavigableSet :
- Child interface of SortedSet
- provides methods for navigating through the elements
- Child classes : TreeSet (before introduction of NavigableSet, this was a child of SortedSet)

6. Queue :
- Child interface of Collection
- data structure which permits removal of objects only from the head.
- Child Classes : PriorityQueue, BlockingQueue->LinkedBlockingQueue, PriorityBlockingQueue

7. Map :
- represents objects as key-value pairs
- Not a child of Collection interface
- duplicate keys not allowed
- Child classes : HashMap->LinkedHashMap, WeakHashMap, IdentityHashMap, Hashtable->Properties

8. SortedMap :
- Child interface of Map
- represents key-value pairs where keys are sorted in some order.

9. NavigableMap :
- Child interface of SortedMap
- provides methods for navigating through the objects in the map
- Child classes : TreeMap (before introduction of NavigableMap in 1.6 version, this was a child of SortedMap)

Map interface hierarchy is similar to Set hierarchy. Map->SortedMap->NavigableMap; Set->SortedSet->NavigableSet

Apart from the above interfaces, Collection framework provides Comparable and Comparator interfaces for sorting the objects. For iterating over the objects, it provides Enumeration, Iterator, and ListIterator interfaces.

Collections and Arrays are the utility classes that provide utility methods that can be used on collection objects and array objects respectively. e.g. Collections.sort() or Arrays.sort()


Image result for collections framework hierarchy

Comments

Popular posts from this blog

Collection Framework - HashSet And LinkedHashSet class

Collection Framework - Cursors in Java

Hashed data structures