By using Array, we can store homogenous data elements. But Array has some limitations.

consider a situation in which you have to store heterogeneous data elements as a single entity. can you do it with an array? no. So, we need a new concept and that new concept is the collection.

As the name suggests, the collection is a group of individual objects.

If we want to represent a group of individual objects as a single entity then we should go for collection.

java provides collection framework which defines several classes and interfaces to represent a collection.

In c++, we have a similar concept of the container which provides standard template library (STL).

Difference between array and collection

Now let’s have a look on the different java collection interfaces.



Please enter your comment!
Please enter your name here