r/learnjava • • Dec 21 '20

ArrayList vs LinkedList

Hi everyone, i want to solve a thought about ArrayList vs LinkedList. I know that ArrayList are basically an resizable array that start from a initial size of 10 (if not otherwise specified in constructor) that is resized everytime you try to put something over its actual length, and LinkedList have items that have pointers to next and previous Object. So linked list are more efficient with removing, adding and set items in the list, cause you don't have to resize all the array or reorder elements but you only change pointers... so the point is -> Why i would choose to use an ArrayList instead LinkedList?

46 Upvotes

15 comments sorted by

View all comments

1

u/aryehof Dec 23 '20

Use an ArrayList when the overhead of resizing is inconsequential. There are cases (particularly in control system software) where that resizing is consequential and therefore a linked list is preferred.