Main differences between Array and ArrayList in java

Posted by

How is an array different from ArrayList ? What are the major differences between Array and ArrayList ? Why difference between Array and ArrayList is the most commonly asked Java Interview Question . Below given are the points for Array vs ArrayList which describes it.

S. No    Array    ArrayList
1Array is fixed length , thus static in natureArrayList  is dynamic in nature
2Array does not extend any class or implement interfaceArrayList implements the List Interface and internally backed by Array
3Array does not support Generics and throws ArrayStoreExceptionArrayList supports Generics and ensures type-safety.

Array provides length() method to calculate

the Array Length


int studentObject[] = new Integer[3];int
int studentObjectLength= studentObject.length ;

ArrayList provides size() method to calculate the ArrayList size

ArrayList studentObject = new ArrayList();

5Arrays allows to store primitive types and objectsArrayList allows to store objects only

Array uses assignment operator to store element into array


int[] studentId = { 101, 102,103,104,105 };

Object[] studentId = new Object[10];

ArrayList uses add() method to store element in ArrayList


ArrayList<Integer> studentIdList = new ArrayList<Integer>();


Arrays are faster when frequent access is required.

Array operations execution time

Arrays Lookup –  O(1)

Arrays Append ( last element) – O(1)

Array Insertion – O(n)

Array Deletion – O(n)

ArrayList is faster when frequent insert and deletion is required.  Overall ArrayList takes  more time as it uses List interface as part of Collection Framework and each node in the List has its own memory when compared to Arrays.

Array is traversed using for loop

ArrayList is traversed using Iterator


Comments are closed.