Code example for ConcurrentModificationException

0
 
        final Entry nextEntry() { 
            if (!hasNext()) 
                throw new NoSuchElementException();
            if (modCount != expectedModCount)
                throw new ConcurrentModificationException();
            lastReturned = next;
            next = reverse ? predecessor(next) : successor(next);
            /// XXX DEBUG 
            if ( lastReturned == NIL ) {
                System.err.println("Encountered NIL in iteration!");
            } 
            return lastReturned;
        } 
 
        public Object next() {
            return nextEntry(); 
        } 
 
        public void remove() { 
            if (lastReturned == NIL)