✅ Java’s LinkedList
is Doubly Linked
Each node in Java’s LinkedList
contains:
- A reference to the next node
- A reference to the previous node
- A value
So it’s a classic doubly linked list.
📦 Internal Structure (Simplified)
private static class Node<E> {
E item;
Node<E> next;
Node<E> prev;
}
That’s from the actual source code of java.util.LinkedList
.
🔄 Why doubly linked?
Because it enables:
- Efficient insertion/removal from both ends (head and tail) → needed for
Deque
- Bidirectional iteration (support for
ListIterator
) - Middle element operations with easier pointer updates
❌ It’s Not:
- Singly linked: would only have
next
, and would be faster and more memory-efficient — but less flexible. - Quadruple linked: doesn’t exist in standard practice, but funny to imagine:
next
,prev
,up
,down
? A grid-based structure like a skip list maybe?
🧠 TL;DR
✅
LinkedList
in Java is doubly linked
❌ Not singly linked
❌ Not quadruple linked — unless you’re building a time-traveling linked list 😂