Java List Implementations: ArrayList, LinkedList, Vector
Fast recall
Quick revision
Core answer
ArrayList (with Collections.synchronizedList) or CopyOnWriteArrayList.Understanding of List implementation trade-offs and ability to match data structure to use case based on time complexity
Claiming LinkedList is always faster for insertions without recognizing that middle insertion still requires O(n) traversal to find the position
Explain that LinkedList implements Deque, making it ideal for queue or stack operations, and mention cache locality advantages of ArrayList
Interview-ready guide
Interview answer
Java has three main List implementations with different performance trade-offs.
ArrayList is the default choice — it's backed by a resizable array, so getting an element by index is instant O of 1, like looking up a spot in an array. Adding to the end is usually O of 1, but occasionally O of n when the array fills up and needs to resize.
The downside is inserting in the middle is O of n because you have to shift all the later elements over. LinkedList is a doubly-linked list where each element points to the next and previous. That makes adding or removing at either end O of 1, which is great for queues.
The catch is if you want the element at index 100, you have to walk through 99 nodes first, so random access is O of n. LinkedList also implements the Deque interface, so you can use it as a queue or stack. 0 — every method is synchronized, which causes unnecessary lock overhead.
We don't use Vector in modern code. If you need thread safety, you'd wrap ArrayList with Collections dot synchronizedList or use CopyOnWriteArrayList for read-heavy scenarios.
One thing that surprises people is ArrayList usually beats LinkedList even for insertion-heavy workloads because of cache locality — array elements sit next to each other in memory, so the CPU loads them in chunks, but LinkedList nodes are scattered all over the heap causing cache misses.
In practice, stick with ArrayList unless you specifically need that O of 1 queue behavior at both ends.
Java List Implementations: ArrayList, LinkedList, Vector
Direct Answer
ArrayList is a resizable array — O(1) random access, O(n) middle insert. LinkedList is a doubly-linked list — O(1) add/remove at both ends, O(n) random access. Vector is a legacy synchronized ArrayList, replaced by ArrayList (with Collections.synchronizedList) or CopyOnWriteArrayList.
Common Mistakes & Pitfalls
- Choosing
LinkedListfor "lots of insertions": Freshers hear "LinkedList is O(1) for insertions" and pick it for any insertion-heavy workload, forgetting that inserting at index 5000 requires O(n) traversal to reach that position first — only head/tail insertions are truly O(1). - Ignoring cache locality:
ArrayList's a compact backing array of references layout lets the CPU load chunks of elements into L1 cache;LinkedListnodes are scattered across the heap, causing frequent cache misses that make real-worldLinkedListslower in many workloads than big-O predicts. - Using
Vectorfor thread safety:Vectorsynchronizes every method call, which still does not protect compound operations like "check size then get last element" — you would need external synchronization, makingVector's built-in locks pure overhead.
Check your understanding
Answer these without looking back at the article.
- When would you choose LinkedList over ArrayList?
- What happens internally when ArrayList runs out of capacity?
- Why is Vector considered legacy?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.