ArrayList stores its elements in a resizable array, while LinkedList stores them as nodes in a doubly linked list. The result is that ArrayList is much faster for reading by index and for most everyday work, while LinkedList offers cheap insertion and removal only when you already hold a position in the list. In practice, ArrayList is the right default for almost every case.
This guide explains how each is built, compares operation costs, and shows why the theory often differs from measured results.
ArrayList wraps an Object[] array. When the array is full, it allocates a larger one (about 1.5 times the size) and copies the elements across. Elements sit next to each other in memory.
LinkedList holds a chain of Node objects. Each node stores the element plus references to the previous and next node, and the list keeps references to the first and last node. LinkedList also implements Deque, so it works as a queue or double-ended queue.
Both lists behave the same through the List interface. The difference is the cost of each operation.
| Operation | ArrayList | LinkedList |
|---|---|---|
get(index) | O(1) | O(n) |
add(element) at the end | O(1) amortised | O(1) |
add(0, element) at the start | O(n) | O(1) |
add(index, element) in the middle | O(n) | O(n) to find, O(1) to link |
remove(index) | O(n) | O(n) to find, O(1) to unlink |
contains(x) | O(n) | O(n) |
| Iteration | Fast, cache friendly | Slower, pointer chasing |
The key point is that LinkedList insertion is only constant time at a position you already hold, for example through a ListIterator or at either end. Reaching the middle by index still requires walking the nodes.
An ArrayList stores one reference per element, plus some unused capacity. A LinkedList creates one node object per element, and each node carries an object header and two extra references. For the same data, a LinkedList typically uses several times more memory and puts more work on the garbage collector.
Modern CPUs load data in cache lines. Elements of an array are contiguous, so scanning an ArrayList is cheap. Nodes of a linked list are scattered across the heap, and each hop can cause a cache miss. Even operations where LinkedList has the better big-O, such as inserting in the middle, often run faster on an ArrayList for lists of moderate size, because shifting a block of memory with System.arraycopy is very fast.
If performance matters for your workload, measure it with a benchmark tool such as JMH instead of relying only on complexity tables.
The one area where LinkedList is natural is the Deque API, with operations at both ends.
Even here, ArrayDeque is usually the better choice. It is backed by a circular array, is faster and uses less memory. The main thing LinkedList offers over it is allowing null elements and implementing List.
ArrayList for lists you read, iterate or append to.ArrayDeque for a stack or queue.LinkedList only when you do many insertions and removals through an iterator at positions you already hold, and measurement confirms a benefit.List.of(...) gives an immutable list.new ArrayList<>(10_000), to avoid repeated resizing.For this kind of filtering, numbers.removeIf(n -> n % 2 == 0) is shorter and, on an ArrayList, does a single pass.
Only at the ends or at a position held by an iterator. Inserting by index in the middle needs a traversal first, and the cache behaviour of an array often makes ArrayList faster anyway.
No. Wrap them with Collections.synchronizedList, or use CopyOnWriteArrayList for read-heavy concurrent access.
Yes. Both allow null elements and duplicate values and keep insertion order.
Prefer ArrayDeque for a single-threaded queue or stack. LinkedList works but uses more memory.
ArrayList is array-backed with constant-time indexed access, compact memory and good cache locality. LinkedList is node-based and cheap to modify only at positions you already hold. Pick ArrayList by default, ArrayDeque for queues and stacks, and LinkedList only when measurement shows it helps.