Iterators --------- A simple example of an iterator. > java Test We have the generic list class GList with the methods - getHead - addFirst - removeFirst - isEmpty - toString But how do we iterate over GList L? We might like to do as follows for (int i=0;i iter = new GIterator(L); while (iter.hasNext()) System.out.println(iter.next()); Ideally we would like to use the foreach construct for (Node x : L) System.out.println(x); however to do this we need to respect class heirarchy to allow the compiler to translate the foreach into the declaration and while above. Therefore what we have done is maybe not "java etiquette" but it will result in the same code. For the true java etiquette see Chap6 Patrick Prosser 2/7/10