public class List // Class to hold reference to first node in the list { private Node head; // only one instance variable public List ( ) // constructor; sets up an empty list { head = null; } public void addToEnd(String itemToAdd) { Node temp = new Node(itemToAdd); Node curr; // needed to traverse the list if (head == null) // if the list is empty head = temp; else //the list is not empty { curr = head; // set curr to the beginning of the list while (curr.next != null) // while not at the end of the list curr = curr.next; curr.next = temp; } } // end addToEnd //other methods go here public String toString() { String temp = ""; Node curr = head; while(curr.next != null) { temp = temp + curr.item + "\n"; curr = curr.next; } return temp; } private class Node // inner class { private String item; // instance variables private Node next; public Node(String i) // constructor { item = i; next = null; } } // end class Node } // end class List