Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $4.99 payment

Question: 1 / 515

Why would you use an ArrayList instead of an array?

ArrayList can only store objects

Arrays can dynamically resize themselves

ArrayList automatically resizes itself

Array elements have a fixed size and cannot dynamically resize themselves while the size of an ArrayList can increase or decrease automatically.

ArrayList also allows for the storage of different types of objects whereas arrays can only store objects of the same type.

Additionally, the foreach syntax can also be used for ArrayLists to simplify the process of accessing its elements.

Array elements can be accessed using foreach syntax

Next

Report this question