| Definition | An Array is a collection of similar data types STORED in contiguous memory locations. | An ArrayList is a class of Java Collections framework which contains popular classes like Vector, HashMap, etc. |
|---|
| Static/ Dynamic | static in SIZE. | dynamic in size. |
|---|
| Resizable | An array is not resizable as it is a fixed-length data structure. | An ArrayList is a variable-length data structure that can be resized. As an element is being added to an ArrayList, JVM checks to see if it has enough space by calling the ensureCapacity method. If a space exists, it adds the element to the ArrayList, otherwise, it resizes the ArrayList.In the resizing process, an array of a larger size is created, the old array is COPIED to the new array using Arrays.copyOf, and the new array is then assigned to the existing array. |
|---|
| Initialization | Size of an array should be declared directly or indirectly while initializing. | An instance of ArrayList can be created without specifying its size. Java creates an ArrayList of default size. |
|---|
| Performance | It is fast in comparison to ArrayList as it has a fixed size. | Slow as the resize operation in ArrayList slows down the performance. |
|---|
| Primitive/ Generic type | Can store both objects and primitives type. | Arraylist automatically converts primitive type to object. |
|---|
| Iterating Values | A for loop or for each loop is used to iterate over an array. | An iterator is used to iterate over ArrayList. |
|---|
| Length | It provides a length variable that DENOTES the length of an array. | size() method can be used to DETERMINE the size of ArrayList. |
|---|
| Single/ Multi-Dimensional | Can be multi-dimensional. | Single-dimensional. |
|---|