import java.util.*; class LinkedListEnumerator implements Enumeration { protected LinkedListEntry pos; public LinkedListEnumerator(LinkedList list) { pos = list.start; } public boolean hasMoreElements() { return (pos != null); } public Object nextElement() { // Make sure the current object is valid if (pos == null) throw new NoSuchElementException(); // Increment the list and return the object LinkedListEntry tmp = pos; pos = pos.next; return tmp.val; } }