1. An array is an indexed collection of fixed number of homogeneous data elements.
  2. The main advantage of arrays is we can represent any number of values by using single name.
  3. Example:
    int[ ] x=new int[600];
    By using x variable we can represent 600 values.By means of index we can differentiate values.

The main limitations of Object Arrays are

  1. Arrays are fixed in size i.e based on our requirements we can’t increase or we can’t decrease the size.hence with respect to memory arrays shows worst performance
  2. Arrays can hold only homogeneous data elements.
    Example:

    Student [] s = new Student [600];
    s[0] = new Student();----->//valid
    s[1] = new Customer();---->//invalid
    

    But we can resolve this problem by using object arrays.

    Object[] a=new Object[600];
    a[0] = new Student();----->//valid
    a[1] = new Customer();---->//valid
    
  3. There is no underlying data structure for arrays hence for every requirement we have to code manually and automatic method support is not available.

We can resolve the above problems by using the Collections

  1. Collections are growable in nature i.e Based on our requirement we can increase/decrease the size.Hence with respect to memory Collections shows excellent performance
  2. Collections can hold both heterogeneous and homogeneous objects
  3. Collections are built based on some data structures hence for every requirement automatic method support is available

Comparison between Collections and Arrays

Collections arrays
Collections are not fixed In size Arrays are fixed In size
With respect to memory collections are good with respect to memory arrays are not good
With respect to performance collections shows worst performance With respect to performance the arrays are recommended to use
Collections can hold heterogeneous data elements Arrays can only hold homogeneous data elements
Every Collection class has built by using some Data structure There is no underlying Data Structure
Collection can hold only Objects but not primitives Arrays can hold both Objects and primitives