1: public void remove() 2: { 3: if (wasNextCalled) 4: { 5: // nextPosition was incremented by the call to next(), so 6: // it is the position number of the entry to be removed 7: list.remove(nextPosition); 8: nextPosition--; // A subsequent call to next() must be 9: // unaffected by this removal 10: wasNextCalled = false; // Reset flag 11: } 12: else 13: throw new IllegalStateException("Illegal call to remove(); " + 14: "next() was not called."); 15: } // end remove 16: // Version 4.0