Difference between Array and ArrayList in Java

The Array and ArrayList class looks same. but they are different in many aspects. so i have listed out some of the differences between these two. Look at the following table.


Array
ArrayList
1
Array stores the values in indexed format. It is primitive data structure.
ArrayList is re – sizable array. It is a collection and stores values as an object.
2
Array is fixed size and can’t grow dynamically.
ArrayList is variable size and can grow or shrink dynamically.
3
Array is used for homogeneous data.
ArraList is used for heterogeneous data.
4
Example:
Int[] arr = new int[5];
for(int i=0;i<5;i++)
arr[i]=i+1;
Example:
ArraList<int> list = new ArrayList<int>();
for(int i=0;i<5;i++)
list.add(i+1);
5
Array can have multi dimensional.
ArrayList only be a single dimensional.
6
Arrays are faster for calculation.
ArraLists are faster for inserting elements.
7
Array is less flexible.
ArrayList is much flexible than Array.