Need of Collection

An array is an indexed Collection of fixed number of homogeneous data elements. The Main advantage of Arrays is we can represent multiple values with a single variable. So that reusability of the code will be improved.

Limitations of Object type Arrays:

1) Arrays are fixed in size i.e. once we created an array with some size there is no chance of increasing or decreasing its size based on our requirement. Hence to use arrays compulsory we should know the size in advance which may not possible always.

2) Arrays can hold only homogeneous data elements.

3) Arrays Concept is not implemented based on some standard data structure hence readymade method support is not available for every requirement we have to write the code explicitly. This increases complexity of programing.

To overcome the above limitations of Arrays we should go for Collections.

Collections are grow-able in nature. I.e. based on our requirement we can increase (or) Decrease the size. Collections can hold both homogeneous & Heterogeneous elements. Every Collection class is implemented based on some standard data structure. Hence readymade method support is available for every requirement. Being a programmer we have to use this method and we are not responsible to provide implementation.

What is Collection?

If we want to represent a group of individual objects as a single entity then we should go for Collection. Collection interface defines the most common methods which are applicable for any Collection Object. In general, Collection interface is considered as root interface of collection framework.

Note: There is no concrete class which implements Collection interface directly.

Last updated