LearnThatStack Ace your next interview
Java · question
Question 9 of 95

What is the difference between ArrayList and LinkedList?

beginner
← All Java questions
Re-explain

ArrayList stores elements in a resizable array, while LinkedList is a doubly linked list of nodes that point to their neighbours. That layout decides which operations are cheap.

ArrayList reads any index in O(1), because it jumps straight to the slot. Adding at the end is amortized O(1), meaning an occasional resize copies the array but the average cost per add stays constant. Inserting or removing in the middle is O(n), because the later elements have to shift.

LinkedList adds and removes at either end in O(1), and in the middle only when an iterator already points there. Reaching an index is O(n), because it walks node by node from the nearer end. So add(index, x) in the middle is O(n) as well.

ArrayList is the usual default, since its per-element overhead is lower. For queue work at the ends, ArrayDeque is often faster than LinkedList.

List<String> arrayList = new ArrayList<>(Collections.nCopies(101, "item"));
List<String> linkedList = new LinkedList<>();
// ArrayList better for
String element = arrayList.get(100); // O(1)
// LinkedList better for
linkedList.add(0, "first"); // O(1)
linkedList.remove(0);       // O(1)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Java cheatsheet.

← Back to all Java questions
Pro · $10/mo

82 of 95 Java answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime