// A class implementing the Iterator interface for MyArrayList.
// Barry Cornelius, 19 June 2000
import java.util. Iterator;
import java.util. NoSuchElementException;
public class MyArrayListIterator implements Iterator
{
   private Object[] iElements;
   private int iSize;
   private int iPosition;
   public MyArrayListIterator(final Object[] pElements, final int pSize)
   {
      iElements = pElements;
      iSize = pSize;
      iPosition = 0;
   }
   public boolean hasNext()
   {
      return iPosition<iSize;
   }
   public Object next()
   {
      if (iPosition==iSize) 
      {
         throw new NoSuchElementException();
      }
      final Object tObject = iElements[iPosition];
      iPosition++;
      return tObject;
   }
   public void remove()
   {
      throw new UnsupportedOperationException();
   }
}
