ArrayList and LinkedList are both List implementations in Java, but they use different internal data structures. ArrayList is implemented using a dynamic array, while LinkedList is implemented as a doubly linked list. These differences directly affect their performance characteristics and use cases.
Internal Implementation of ArrayList
ArrayList stores elements in a dynamic array called elementData.
[element1][element2][element3][element4]
get(index) → O(1)
O(n)
because elements need to be shifted.
Index: 0 1 2
Data: Java Spring Hibernate
list.get(2)
Directly retrieves "Hibernate".
Internal Implementation of LinkedList
LinkedList is implemented as a doubly linked list.
null <- [Java] <-> [Spring] <-> [Hibernate] -> null
get(index) → O(n)
O(1)
Suppose we need to add a new element between Java and Spring.
Java, Spring, Hibernate
Insert "Microservices"
Elements must be shifted.
Java <-> Spring <-> Hibernate
Only node references are updated.
No element shifting is required.
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class Demo {
public static void main(String[] args) {
List<String> arrayList =
new ArrayList<>();
arrayList.add("Java");
arrayList.add("Spring");
List<String> linkedList =
new LinkedList<>();
linkedList.add("Java");
linkedList.add("Spring");
System.out.println(arrayList);
System.out.println(linkedList);
}
}[Java, Spring]
[Java, Spring]
Operation ArrayList LinkedList
Random Access O(1) O(n)
Insert at End O(1)* O(1)
Insert in Middle O(n) O(1)**
Delete in Middle O(n) O(1)**Memory Usage Lower Higher
* Amortized O(1)
** After locating the nodeWhen to Use ArrayList?
When to Use LinkedList?
A concise interview answer is
ArrayList is internally implemented using a dynamic array, which provides O(1) random access but requires shifting elements during insertions and deletions. LinkedList is implemented as a doubly linked list, where each node stores references to the previous and next nodes, making insertions and deletions efficient but random access slower at O(n).
Last updated: 16 July 2026
Previous question: Can you give an example where a TreeSet is more appropriate than HashSet?
Next question: How does HashMap work internally in Java?