ArrayList vs LinkedList in Java: Complete Comparison
Fast recall
Quick revision
Core answer
get/set) but O(n) inserts/removals in the middle (elements shift). LinkedList is a doubly linked list, giving O(1) add/remove at the ends but O(n) random access (you must walk the nodes). In practice ArrayList wins usually due to cache locality and lower memory overhead; LinkedList only shines for heavy head/tail (queue/deque) operations.Whether you map each operation to its real complexity and know which one to default to
Saying 'LinkedList is faster for insertion' without noting you still pay O(n) to reach the insertion point
Mention cache locality and that ArrayDeque, not LinkedList, is the modern choice for queues
Interview-ready guide
Interview answer
Both ArrayList and LinkedList implement the List interface, so they expose the same methods — the difference is how they store data internally.
ArrayList is backed by a resizable array. element references occupy consecutive slots in the backing array, so getting an element by index is a direct calculation, which is constant time. The downside is inserting or removing in the middle, because everything after that point has to shift, which is linear time.
When the array fills up, ArrayList grows by about fifty percent and copies into a bigger array. LinkedList is a doubly linked list. Each element lives in a node that holds the value plus references to the previous and next nodes.
Because there's no index math, reaching position i means walking i nodes, so random access is linear time. But adding or removing at the head or tail is constant time, since you just relink a couple of references. Here's the subtle point interviewers love: even LinkedList's middle insertion is linear time, because you first have to traverse to the spot before you relink.
In practice, ArrayList wins almost every time. Its a compact backing array of references means great cache locality, so iteration is much faster, and it uses far less memory per element — just one reference versus a node with two references. LinkedList only shines when you do lots of head and tail operations and rarely index.
And even then, for a queue or stack, the modern choice is ArrayDeque, which is array-backed and beats LinkedList on both speed and memory. So my default is ArrayList, and I reach for ArrayDeque when I need queue behavior.
ArrayList vs LinkedList in Java: Complete Comparison
Direct Answer
ArrayList is backed by a resizable array, giving O(1) random access (get/set) but O(n) inserts/removals in the middle (elements shift). LinkedList is a doubly linked list, giving O(1) add/remove at the ends but O(n) random access (you must walk the nodes). In practice ArrayList wins usually due to cache locality and lower memory overhead; LinkedList only shines for heavy head/tail (queue/deque) operations.
Common Mistakes & Pitfalls
- Over-claiming LinkedList inserts. Saying "LinkedList is faster for insertion" ignores the O(n) traversal needed to reach the insertion point — the relink is O(1), but getting there is not.
- Indexed loops on a LinkedList.
for (i...) list.get(i)is O(n^2); iterate with a for-each orIteratorinstead, which is O(n). - Using LinkedList as a default queue.
ArrayDequeis array-backed, faster, and lighter for queue/stack work — reach for it beforeLinkedList. - Ignoring cache locality. ArrayList's a compact backing array of references usually wins in real benchmarks even where the Big-O of two operations looks identical.
Check your understanding
Answer these without looking back at the article.
- What is the memory overhead per element in LinkedList?
- In what scenario does LinkedList clearly outperform ArrayList?
- What is cache locality and why does it favor ArrayList?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.