What is LinkedList in Java?
👉 LinkedList is a linear data structure implementation in Java that stores elements as nodes connected using pointers (links).
Instead of an array, it uses:
Node structure
Each node has:
data
reference to next node
reference to previous node 🔹 Key features ✔ 1. Dynamic size Grows and shrinks automatically No fixed capacity like arrays ✔ 2. Fast insert/delete No shifting required Just change links Example:
Insert B between A and C → just update pointers
✔ 3. Slow random access
list.get(5);
👉 Must traverse node-by-node → O(n) time
🔹 Constructors in LinkedList
✔ Default:
LinkedList < String > list = new LinkedList <>();
Enter fullscreen mode
Exit fullscreen mode
✔ From collection:
LinkedList < String > list = new LinkedList <>( otherList );
Enter fullscreen mode
Exit fullscreen mode
Important interfaces it implements
LinkedList implements:
List
Deque
Queue
So it can act like:
List
Stack
Queue
🔹 1.…