What is the difference between ArrayList and LinkedList in Java?

PointArrayListLinkedList
InsideResizable arrayDoubly linked nodes
Get by indexFast, O(1)Slow, O(n)
Add at the endFast (usually)Fast
Add or remove at the startSlow, O(n)Fast, O(1)
MemoryLessMore (each node has two links)
Also a DequeNoYes

In practice ArrayList is the better choice for almost all cases, because of its simple memory layout. For a queue or a stack use ArrayDeque. See Java HashSet and LinkedList.


Learn more about the similar topics:
Tutorials
Java ArrayList
Java HashMap
Java HashSet and LinkedList
Java Generics
Exercises & Assignments
Sort a list of students with a Comparator
Count the frequency of words with a HashMap
Remove duplicates from a list and keep the order
Interview Questions & Answers
What is the difference between an array and an ArrayList in Java?
How does HashMap work internally in Java?
What is the difference between HashMap, Hashtable and ConcurrentHashMap?
Why must you override both equals() and hashCode() in Java?
What is the difference between Comparable and Comparator in Java?
What is the difference between ArrayList and LinkedList in Java?
What is the difference between fail-fast and fail-safe iterators?