Skip to content
UniCircle
MediumConceptualCollections

ArrayList vs LinkedList

Question JAVA-COL-026

Compare ArrayList and LinkedList. Which would you use by default, and why?

Show the explanation
OperationArrayList (resizable array)LinkedList (doubly linked)
get(i)O(1)O(n) — walks the list
add at endamortised O(1)O(1)
add/remove at front or middleO(n) — shifts elementsO(1) once you are at the node, but finding it is O(n)
Memory per elementone referencenode with two extra pointers
CPU cachecontiguous, fastscattered, slow

Default to `ArrayList`. Random access is constant time, and even inserts in the middle are usually fast in practice because shifting a contiguous array is cheap. LinkedList rarely wins; for a queue or stack, ArrayDeque is faster than both.

Java
List<String> names = new ArrayList<>();      // program to the interface
Deque<Integer> stack = new ArrayDeque<>();   // instead of Stack or LinkedList
stack.push(1); stack.push(2); stack.pop();   // 2

Declaring variables as List/Deque (the interface) means you can switch implementations later without changing callers.

Original UniCircle question. Last reviewed 22 Oct 2026.