/** * This code is from the book: * David Glanagan: Java in a Nutshell * O'Reilly, Sept. 1997 * It is copyright (c) 1997 David Flanagan */ import java.util.*; public class l1Lock3{//LinkedList //Top level nested interface, body elided public interface Linkable{....} //List head private Linkable head; //Other methods public void addToHead(Linkable node){...} public Linkable removeHead(){...} //Enumeration object for this linked list public Enumeration enumerate(){ //Local class class Enumerator implements Enumeration{ Linkable current; public Enumerator(){ this.current=LinkedList.this.head; } public boolean hasMoreElements(){ return(current != null); } public Object nextElement(){ if (current == null) throw new NoSuchElementException(``LinkedList''); Object value = current; current = current.getNext(); return value; } } return new Enumerator(); //instance of Local Enumerator class } }