r/learnjava • u/maybe_tom__ • 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
1
u/HecknChonker Dec 21 '20
Also check out ArrayDeque. It's a double ended queue that can be used as a stack or queue or list. ArrayList is still better in most cases, but this is a good one to be familiar with.