public class LinkedList {
public boolean isEmpty();
public int size();
public void addFirst(Object item);
public Object firstItem();
public void removeFirst();
public boolean contains(Object item);
public void reverse();
public Iterator iterator();
public boolean equals(Object other);
public String toString();
}
The approach here is deliberately simple. A list will be represented internally by a single ListNode constituting the head of the list. We shall use the device of setting this to be null to indicate an empty list. A more elegant approach to the problem of representing empty structures, but one which is a little less straightforward, will be adopted later when we deal with binary search trees.