In order to store multiple values or objects of the same type, Java provides two types of data structures namely Array and Collection.
The following are the important differences between Arrays and Collection.
|1||Size||Arrays are fixed in size i.e once the array with the specific size is declared then we can't alter its size afterward.||The collection is dynamic in size i.e based on requirement size could be get altered even after its declaration.|
|2||Memory Consumption||Arrays due to fast execution consumes more memory and has better performance.||Collections, on the other hand, consume less memory but also have low performance as compared to Arrays.|
|3||Data type||Arrays can hold the only the same type of data in its collection i.e only homogeneous data types elements are allowed in case of arrays.||Collection, on the other hand, can hold both homogeneous and heterogeneous elements.|
|4||Primitives storage||Arrays can hold both object and primitive type data.||On the other hand, collection can hold only object types but not the primitive type of data.|
|5||Performance||Arrays due to its storage and internal implementation better in performance.||Collection on the other hand with respect to performance is not recommended to use.|