Nodes and linked lists
Read · 1 of 3
A node knows the next node
A linked list is a chain of nodes. Each node holds a value and a reference to the next node; the last one's next is null.
To visit every value, start at the head and keep following .next until you reach null.
1class Node {2 int val;3 Node next;45 Node(int val) {6 this.val = val;7 }8}