Collection Framework

Collection framework provides us a dynamically allocated data structures which is used to store and manipulate the group of objects. A collection, as its names suggest is simply an object that holds a collection or group of objects. Each item in a collection is called an element. A framework, is basically a set of interfaces that encourage you to use its predefined design practices.

Collection Framework in Java contains:

  • A set of interfaces,
  • Implementation classes, and
  • Algorithms (such as searching and sorting).

Java Collection framework provides multiple interfaces (List, Set, Queue, Deque etc.) and classes (ArrayList, LinkedList , Vector, PriorityQueue, HashSet, TreeSet, LinkedHashSet etc).

In one liner we can say:
1) Collection : Collection is a group of individual object as a single entity.
2) Collection framework: Collection framework define several classes and interface which can be used a group of objects as single entity.

See below image for concise details:

Java Collection Framework consists with the following parts as we discussed above:


Java Collections Framework provides a set of interfaces to represent collection. Collection(java.util.Collection) is the root interface of Collections Framework. It is on the top of Collections framework hierarchy. It contains some important methods like(add(), remove(), clear(), size(), Iterator etc) that every Collection class must implement. Some other important interfaces are List, Set, Queue, Deque and Map. Map is the only interface that doesn’t inherits from Collection interface but it’s part of Collections framework.

Implementation classes:

Classes under Collection Framework is used to create different types of collections in Java program.
Some important classes are ( ArrayList, LinkedList , Vector, PriorityQueue, HashSet, TreeSet, LinkedHashSet etc). These classes helps most of our programming needs but if we need some special collection class, we can extend these classes to create our custom collection class.


Algorithms are important methods to provide some common functionalities. For example searching, sorting etc.

Collection Framework benefits:

Below are few benefits Of Collection Framework:

1. Enhance programming speed and quality:
The Collection Framework provides us the implementation of data structures and algorithms which freed the developer from core logics and their own data structures. Developer have more time to improve code quality.

2. Reduces programming effort:
Java Collections Framework provides common classes and utility methods than can be used with different types of collections. Its reusable code frees us to concentrate on requires part rather than the low level programming.

3. Reduces effort to learn and design new APIs:
Many Java API usually use Collection as input and provide them as output. Developers do not have to recreate API that relies on Collection Framework instead, they can use standard collection interfaces.

4. Easy to maintain:
Most of the Java Collections framework code is open source and API documents is widely available, it is easy to maintain the code written with the help of Collections framework.

5. Algorithms:
Algorithms are the methods that perform useful computations, like searching and sorting on Collection elements.

6. Hold heterogeneous elements:
Collections can hold heterogeneous data elements means we can store different type of data elements with in a single collection.