package dk.itu.oop.lecture5; public class ArrayIterator implements OOPIterator{ private final Object[] theArray; private int index; // index of next element public ArrayIterator(Object[] objects){ theArray = objects; index = 0; } public boolean hasNext(){ return index < theArray.length; } public Object next(){ return theArray[index++]; } public Object peek(){ return theArray[index]; } public OOPIterator cloneMe(){ try{ return (OOPIterator)super.clone(); }catch(CloneNotSupportedException shouldNotHappen){ throw new Error("Object claims not to be able to clone"); } } }