An array is an index & collection of fixed number of homogeneous data element.
Limitation of object arrays:
- Arrays are fixed in size i.e., one we created an array there is no chance of increasing or decreasing size based on our requirement. Hence, to use arrays concept compulsory we should know the size in advance, which may not possible always.
- Arrays can hold only Homogeneous data element i.e., (same type)
Ex : Student S = new Student[1000];
S[0] = new Student[];
S[1] = new Student[];
S[2] = new Customer[];
- But we can resolve this problem by using object type arrays.
Ex : Object[] a = new Object[1000];
A[0] = new Student[];
A[1] = new Customer[];
- Array concept not built based on some data structure. Hence ready made method support is not available for ever requirement. Compulsory programmer is responsible to write the logic.
- To resolve the above problem some people introduced Collections concept.
Advantages of Collections over arrays:-
- Collections are growable in nature. Hence, based on our requirement we can increase or decrease the size.
- Collections can hold both Homogeneous & Heterogeneous objects,
- Every collection class is implemented based on some data structure. Hence ready-made method support is available for every requirement.
Disadvantage of Collections:-
Performance point of view collections are not recommended to use. This is the limitation of collections.