Class IteratorExample.AnIterator

java.lang.Object
  extended byIteratorExample.AnIterator
All Implemented Interfaces:
java.util.Iterator
Enclosing class:
IteratorExample

protected class IteratorExample.AnIterator
extends java.lang.Object
implements java.util.Iterator

Inner iterator class that defines the iterator instance returned by this.iterator.


Constructor Summary
protected IteratorExample.AnIterator()
           
 
Method Summary
 boolean hasNext()
          Return true if there are items left to generate.
 java.lang.Object next()
          Return the next item as an Integer, throwing NoSuchElementException when no more.
 void remove()
          Remove does nothing here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorExample.AnIterator

protected IteratorExample.AnIterator()
Method Detail

hasNext

public boolean hasNext()
Return true if there are items left to generate.

Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
Return the next item as an Integer, throwing NoSuchElementException when no more. Note that to implement the java.util.Iterator interface properly, the next method must return Object, which means that the ints stored directly in this class must be promoted to Integer.

Specified by:
next in interface java.util.Iterator

remove

public void remove()
Remove does nothing here. According to the JFC documentation, this is allowed, i.e., remove is defined as an "optional operation".

Specified by:
remove in interface java.util.Iterator