java - Array or ArrayList -
i familiar using arrays came across arraylist , wondering if typically use arraylist more regular array?
for reference arraylist looks :
arraylist<dog> mydogarraylist = new arraylist<dog>();
regular array:
string [] dog = new string(type)
arraylist
s (or, in general, collections) intended heavy read , write operation without thinking capacity, extension , forth (in first place). more comfortable call arraylist#add
creating new array size oldarray.length + 1
, doing system.arraycopy
, adding element. there lots of handy methods (indexof
, remove
, sublist
) leverage complexity of use in comparison arrays.
if take @ collections
class, you'll find lot of convenience methods shuffle
or reverse
.
the use of list
in general more common arrays, except you're heading performance.
Comments
Post a Comment