Java


Java Tutorial


Admission Enquiry Form


Collection Object in Java



Before learning Collections Framework we will discuss about array.

Q1. How we can handle a group of elements?

Ans. We use Array to store a group of elements and handle them easily.

Q2. How we can handle a group of Objects?

Ans. Again We can use Array to store a group of Objects.

Using array we can store a group of objects and retrieve them easily.

But there are also certain inconveniences in this mechanism.They are as follows:

  • We cannot store different class objects into the same array, because array can store only one data type elements.
  • Adding the object at the end of an array is easy. But, inserting and deleting in the middle of the array is difficult.
  • Retrieving the elements from an array is easy but after retrieving the elements, if we want to process them, then there is no methods available to carry out this.

Due to these problems, programmers want a better mechanism to store a group of objects.
The alternative is using an object to store a group of objects. It means that we can use a class object as an array.Such an object is called

'Collection Object'

Or

'Container Object'






What is Collection Object ?

A collection object or a container object is an object which can store a group of other objects.

A collection object has a class called as 'Collection Class' or 'Container Class'. All the collection classes are available in the package -: 'java.util' (Here , util stands for utility).