public class Driver { public static void main(String [] args) { List aList = new List(); aList.display(); } } public class List { private Node head; public List() { final int max = 3; int i; head = null; Node aNode = new Node(0); for (i = 0; i < max; i++) { aNode.num = i; add(aNode); aNode.next = null; } } public void add(Node aNode) { Node temp; if (head == null) head = aNode; else { temp = head; while (temp.next != null) temp = temp.next; temp.next = aNode; } } // Assume it displays the list properly from start to finish public void display() { Node temp = head; while (temp != null) { System.out.print(temp); temp = temp.next; } // while loop } // display() } // Class List public class Node { public int num; public Node next; public Node(int aNum) { num = aNum; next = null; } public String toString() { return(Integer.toString(num)); } }