A collections framework is a unified architecture for
representing and manipulating collections that reduces
programming efforts. It provides
High-performance and high-quality mplementations of useful data structures and algorithms, thus it frees developers to concentrate on the important parts of a program i.e. quality and performance
rather than worrying about the low-level issues required to make it work.
Introduction to Java Collections API
Java Collections API supports, a set of data structures
that includes ArrayList, Map, HashSet, etc. A
collection is simply an object that groups multiple elements
into a single unit. It can be thought as a container
that is used to store, retrieve, manipulate, and communicate aggregate data.
It groups data items and allows accommodating
duplicate elements. It may consist of both ordered and
Earlier versions of the Java (pre-1.2) included generalized
collection implementations like vector, hashtable,
and array but not the collections framework. Hence the
new version of the Java platform contains the collections
Let’s explore the collections framework
A collections framework is used to represent and
manipulate collections. Basically it is a unified architecture
that consists of:
1. Interfaces: These are abstract data types that
represent collections. With the help of interfaces we can
manipulate collections without worrying about their
implementation details. A hierarchy is generally formed
by interfaces in object-oriented languages.
2. Implementations: They are the reusable data
structures with the concrete implementations of the
3. Algorithms: Algorithms are used to perform
computations, such as searching and sorting, on objects
that implement collection interfaces. They provide
reusable functionality i.e. the same method can be used
with different implementations of collection (appropriate)
interface. Hence they are said to be polymorphic.
4. General-purpose Implementations: These are
general implementations of the collection interfaces at
the primary levels.
5. Infrastructure: They are the interfaces that
provide essential support for the collection interfaces.
6. Array Utilities: Provides classical utility functions
for arrays of primitives and reference objects. This utility
was added to the Java platform as a part of the Collections
The figure below shows the hierarchy of collection
Advantages of collections framework
1 A programmer need not to learn multiple ad hoc
2 It provides a standard interface for collections
that fosters software reuse along with the algorithms
to manipulate them.
3 It provides ready-made data structures and
algorithms that reduce programming effort by eliminating
the need to write them from scratch.
4 It provides high-performance implementations of
useful data structures and algorithms that increase
5 Helps in establishing a common language to pass
collections back and forth that provides
interoperability between unrelated APIs.
Introduction to Java 6.0 Collections AP
I Some of the new collections APIs have been introduced
in Java 6.0. These are:
1. Deque: It is used to represent a double ended
queue. This collection helps to add or remove elements
at both the ends. Deque implementation can be used as
a stack (Last in first out) or as a queue (First in First
Out). There are methods in Deque used for insertion,
retrieval and removal of elements. All the Deque methods
exist in two forms, one method returns status or special
value for each operation and the other one throws
exception if it fails in an operation.
2. BlockingDeque: It is similar to Deque but with
added functionality. When we try to insert an element in a
BlockingDeque and if the blockingDeque is already full
then the element waits till the space becomes available to