+ 2

Why the need for arrayList when there's Array to handle things in Java?

Array not enough

13th Feb 2017, 8:45 AM
Yahaya Harboubacar Danjuma
Yahaya Harboubacar Danjuma - avatar
2 Respostas
+ 7
Simply stating, 1) Removing an element from an array is hard and needs a loop. But, just 'remove()' function can be used to remove an element from an arraylist. 2) Adding an element to an array is hard and needs a loop. But, just 'add()' function can be used to add an element to an arraylist. Arraylists are advantageous because they can be dynamically changed very easily.
13th Feb 2017, 11:50 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
Array list is more flexible than a normal Array, so if you have multiple items that you need to store in an array that needs to change over time too then an Array list can be great for you.
13th Feb 2017, 10:00 AM
Ghauth Christians
Ghauth Christians - avatar