Introduction
In this article, we discuss the Collection Framework in Java and start working with the ArrayList class.
Collection Framework
The Collection Framework provides an architecture to manipulate and store a group of objects. It is a set of classes and interfaces that implement commonly reusable collection data structures. Every operation performed on the data, like sorting, searching, insertion, deletion, etcetera can be done by the Java Collection Framework.
The Collection Framework was designed to meet the following goals:
- It allows various types of data types to work in a similar manner.
- It is easy to adapt or extend a group of data.
- It provides a high rate of performance.
Collection
It represents a single unit of objects.
Framework
The Framework:
- represents the set of classes and interfaces.
- is optional in nature.
- provides a specified architecture.
Collection Framework
The Collection Framework represents a predefined architecture for storing and manipulating the group of objects.
It has:
- Interfaces and it implements, in other words, classes
- Algorithms
Hierarchy of Collection Framework
Let us see the hierarchy of the Collection Framework.
Some commonly used public methods are:
- boolean remove (Object element)
- used to delete an element from this collection.
- boolean removeAll (Collection cln)
- used to delete all the elements of the specified collection from the invoking collection.
- boolean retainAll (Collection cln)
- used to delete all the elements of an invoking collection except the specified column.
- boolean add (object element)
- used to insert an element in this collection.
- boolean addAll (collection cln)
- used to insert the specified collection elements in the invoking collection.
- int size()
- returns the total number of elements from the collection.
- void clear()
- removes the total number of elements from the collection.
- boolean contains (object elements)
- used to search an element.
- boolean containsAll (collection cln)
- used to search the specified collection in the collection.
- Iterator iterator()
- returns an iterator.


Join the conversation! Your thoughts help the community grow.