-1

So I understand that an ArrayList has a variable length unlike an Array, but what are some of the advantages of using one over the other?

Patrick
  • 87
  • 1
  • 7
  • If you know how big your array will be then use Array, however I would reccomend looking at generic collection instead of ArrayList – Matthew North May 29 '15 at 13:37

2 Answers2

1

Array takes up less space and are typically faster, ArrayList lets you add and remove elements from your array (can be useful for a lot of reasons).

NendoTaka
  • 1,224
  • 8
  • 14
0

Array is perfect, if you have a fixed number of items. It is fast and can be accessed by index.

ArrayList is more flexible, the list can easily extended by using add() function. ArrayList can also be accessed by index (using get(int i)).

So at the end it boils down to fixed length or not.

Thirdman
  • 621
  • 7
  • 13