The following code fragment creates a linear structure with 3 nodes containing characters.
class ListNode {
String info;
ListNode next;
}
public class TestList {
public static ListNode create3NodesABC() {
ListNode a = new ListNode();
ListNode b = new ListNode();
ListNode c = new ListNode();
a.info = "A";
a.next = b;
b.info = "B";
b.next = c;
c.info = "C";
c.next = null;
return a;
}
}
The following figure shows a representation in memory of the list created by the method above.

Note: In the following, we will use a more compact graphical representation of ListNode objects and lists. Specifically, the above list will be represented as follows.
