ArrayList vs LinkedList
35 min · Intermediate
ArrayList keeps elements in one resizable array, while LinkedList keeps each element in its own node joined by links. Almost every Java interview asks you to compare them, and the strong answer covers internals, Big-O, real-world speed and the traps around remove and fixed-size lists.
Topics in this lesson
- Internals: resizable array vs doubly linked nodes
- Big-O table for the common operations
- Why ArrayList usually wins in practice
- The collection hierarchy: List vs Set vs Queue vs Map
- Traps: remove(int) vs remove(Object), Arrays.asList and List.of
Interview questions this lesson answers
- What is the difference between ArrayList and LinkedList?
- How does an ArrayList grow internally?
- Inserting in the middle is O(n) for both lists. So which is faster?
- When would you actually choose LinkedList?
- Why does Map not extend Collection?
- What is the difference between Arrays.asList and List.of?
- On a List<Integer>, what does list.remove(1) do?
- Is ArrayList thread-safe? What about Vector?
- What is the default capacity of an ArrayList?
- What is the difference between size and capacity?
Sign in free to continue this lesson
Create a free account to read every lesson, practise with the exercises and keep track of your progress.