Skip to main content

LinkedList

Learn LinkedList (List Interface, Collection Framework) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is a LinkedList? A LinkedList stores its elements in separate little objects called nodes . Every node holds one element and two links: one to the previous node and one to the next node. Picture a chain of forts connected by roads in both directions: to go from the first fort to the fourth you must walk through the second and the third. There is no numbered shelf like in an array. It lives in java.util . It implements List (indexes, order), Deque and Queue (work at both ends). Fast at the two ends: adding or removing the first or last element changes only a couple of links: O(1). Slow in...

More lessons in List Interface