/** * From Java Tutorial Second Edition 1998 * David Flanagan, O'Reilly */ public class Stack { private Vector items; ... //code for Stack's methods and //constructors not shown... public Enumeration enumerator() { return new Enumeration() { int currentItem = items.size() - 1; public boolean hasMoreElements() { return (currentItem >= 0); } public Object nextElement() { if (!hasMoreElements()) throw new NoSuchElementException(); else return items.elementAt(currentItem--); } } } }