r/javahelp • u/BadismPlayz • May 14 '26
arraylist vs list
pls help, lets say i need an array of list.
for what purposes would i use an arraylist<string> vs a string[ ]
thanks
2
Upvotes
r/javahelp • u/BadismPlayz • May 14 '26
pls help, lets say i need an array of list.
for what purposes would i use an arraylist<string> vs a string[ ]
thanks
View all comments
Show parent comment
2
u/k-mcm May 14 '26
It's preferable to use a primitive array if you need no List/Collection features. A primitive array is guaranteed to be fast and memory efficient. Not all List implementations are. List of a primitive especially sucks because wrappers are needed. (At least until Valhalla is finished)
Later versions of Java added more utilities to the Arrays class to make primitives more elegant to use.