Collection in java

In this post, we will read the most important part of java that is java collection framework, and see all the collection in java. In java collections tutorial we will cover the collection hierarchy in java and collection in java with examples.

Here is the table content of the article will we will cover this topic.
1. What is the Collection framework?
2. The need of Collection Framework?
3. How does the Java Collections Framework work?

What is the java collection framework?

In java, the Collection is a framework that provides an architecture used to store and manipulate the group of objects. To operate the group of objects we need to understand the Collection framework. By use of Collection framework, a programmer can manage/operate the group of objects. The Collection framework can perform searching, sorting, insertion, manipulation, and deletion operations as you perform on data. The group of objects treated as a single unit in the Collection framework.

Java Collection framework provides some interfaces that are known as collection interfaces in java and some classes that are known as collection classes in java. We will discuss all the classes and interfaces of the java collection framework in depth and also try different scenarios of java collections programs.

collection in java

The need of Collection Framework?

Before moving each interface and class of collection framework we should know what is the need for a framework. Before JDK 1.2, Java supported the group of objects by using Dictionary, Properties, Stack, and Vector class. These classes were used for manipulating and performing an operation on the group of objects. But there were some problems in classes like lacking a central, unifying theme. Each class had a different way to operate the objects. So, the programmer was facing lots of problems managing the group of objects.

To resolve these problems the collection framework was designed for data collection organization and management. The collection framework is a robust, reliable, and high-performance mechanism. It allows various collections to operate and manage. In collection has many interfaces and classes.
Each data collection implements an algorithm such as a linked list, hash set, tree set. The algorithm used in the framework is the base on each data collection and can be inherited by the child class.

The collection framework has interfaces and classes:

  • Collection Interfaces in java : Collection framework has many interfaces. The interfaces allow for the manipulation of collections that are independent of their representation details.  
  • Collection Classes in java: Collection framework has many classes that provide concrete implementations to the collection interfaces.

How does the Java Collections Framework work?

In the collection framework, each interface and class are based on an algorithm. Actually, the algorithm is nothing, it just the way data is organized in the collection object. The algorithm supports the objects to perform basic operations like sorting, searching, etc.

These algorithms have methods that provide the same output in different implementations. In the collection, interfaces have some abstract methods whenever any class implements an interface then implementing class automatically that provides the functionality. Because all structure is based on a common algorithm. The collection framework is divided into two components:

1. collection interfaces: The framework has a lot of interfaces that provide just the declaration of methods. We will cover each interface in a separate topic. The framework has the following interfaces:

2. collection classes: All the interface of the collection are implemented by classes and these classes provide body to the method of interfaces. We will cover each class in a separate topic. The framework has the following classes:

Note: The Map is not part of the collection framework. The Map was introduced after the version of JAVA 1.2, but the collection framework also supports Map interfaces and classes.

2 thoughts on “Collection in java”

Leave a Comment