private class LinkedListIterator implements ListIterator { . . . public Object next() { if (!hasNext()) throw new NoSuchElementException(); previous = position; // remember for remove if (position == null) position = first; else position = position.next; return position.data; } . . . }