Home » Array vs ArrayList in Java

Array vs ArrayList in Java

by Online Tutorials Library

Array vs ArrayList in Java

Array is a fixed length data structure whereas ArrayList is a variable length Collection class. We cannot change length of array once created in Java but ArrayList can be changed.

We cannot store primitives in ArrayList, it can only store objects. But array can contain both primitives and objects in Java. Since Java 5, primitives are automatically converted in objects which is known as auto-boxing.

Output:

Traversing List... 10 20 30 

You may also like