1 public class ArrayListIterator implements Iterator {
5 private ArrayList list;
7 public ArrayListIterator(ArrayList list) {
10 this.size = this.list.size();
15 * Tests to see if there are any more objects to
18 * @return True if the end of the list has not yet been
21 public boolean hasNext()
27 * Retrieves the next object from the list.
29 * @return The next object.
30 * @throws NoSuchElementException if there are
31 * no more objects to retrieve.
32 * @throws ConcurrentModificationException if the
33 * list has been modified elsewhere.
38 throw new /*NoSuchElement*/Exception("NoSuchElementException");
40 return this.list.get(pos++);
44 * Removes the last object retrieved by <code>next()</code>
45 * from the list, if the list supports object removal.
47 * @throws ConcurrentModificationException if the list
48 * has been modified elsewhere.
49 * @throws IllegalStateException if the iterator is positioned
50 * before the start of the list or the last object has already
52 * @throws UnsupportedOperationException if the list does
53 * not support removing elements.
58 throw new /*IllegalState*/Exception("IllegalStateException");
59 this.list.remove(last);