Skip to content
UPEEC

ArrayList and LinkedList

Two List implementations with different performance trade-offs.

Easy
Comments 0
OperationArrayListLinkedList
Get by indexO(1)O(1)O(n)O(n)
Add at endO(1)O(1) amortisedO(1)O(1)
Insert/remove in middleO(n)O(n)O(1)O(1) once positioned
Memorycompactextra node objects

ArrayList is the right default almost always. For queues use ArrayDeque.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.