Collection Framework
If we are representing a group of individual objects in a single unit/entity, it is known as a collection. In Java, It is named as a "Collection Framework". The Collection Framework has been defined in JDK 1.2(December 1998). The Collection framework has several interfaces and implementations. i.e., classes.
Key interfaces of Collection Framework.
- Collection
- List
- Set
- SortedSet
- NavigableSet
- Queue
- Map
- SortedMap
- NavigableMap
Advantage of Java Collection Framework
- Reusability:- Collection framework provide common set of classes and methods that reduce the duplication of code for the same types of common operations. like add(), addAll() etc.
- Speed:- Due to the pre-define methods for the common operations it's helps to increase the development speed.
Hierarchy of Collection Framework.
1. Collection(I)
Collection Interface is the Root of the Interface inheritance hierarchy for the Collection Framework. As the root interface for the collection framework, it has common methods for all the collection framework interfaces and classes. There is no concrete class available that implements the Collection interface directly.
2. List(I)
The List interface is the child interface of the Collection. Maintaining their elements in order means every element has a position in the list. The List can contain duplicate values. As the List preserves the insertion order, the position of an element can change as elements are inserted or deleted from the list.