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) 

arraylists (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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -