For example following code throws ArrayStoreException. " ArrayStoreException" if it is not able to resolve it at run time. Since Array knows the type of the data which it can hold so it will give compiler error " Type Mismatch" or Difference number 2 between array and ArrayList also indicates one more difference, which is about " type safety".Wrapper class Integer- List myList = new ArrayList() In case of ArrayList if you want to store integers then you have to do this, note the use of Or, if you have a class Employee and you want an array of size 5 to hold 5 Employee objects then- Employee employees = new Employee Though Autoboxing and Unboxing has blurred that difference, but the important point to note here is that in case of ArrayListĪny primitive data type is still wrapped and stored as an Object.įor example, if you want an array of primitive type int- int intArray = new int Array can store both primitive types as well as objects whereas ArrayList can store only objects.Refer: How ArrayList works internally in Java to know more about the internal implementation of ArrayList. Is not able to fit in the number of elements stored in the ArrayList. Object internally, but it has the logic to keep growing the size of the array as and when previous size Whereas ArrayList is dynamic and that is why also known as dynamic array. First and the most important difference is Array is static and can't be resized once declared.In this post we'll see some of the differences between ArrayList and Array in terms of how they are initialized and Though performance wise both Array and ArrayList may give almost similar performance but functionality wise they both are used in quite different scenarios. Difference between Array and ArrayList in Java is one question you may come across in a Java technical interview.