David M. Karr (83) [Avatar] Offline
#1
Section 4.4.1 and the paragraph before it fails to mention that this is one area where Groovy can't do something that Java can (as far as I can tell). Although it may be said that modifying a collection while iterating through it is not a good idea, it's certainly possible to do this in Java, as long as you use the Iterator methods, and not the collection methods. Using "iterator.remove()" in a loop is perfectly legal in Java, and will not throw a ConcurrentModification error.

The Javadoc for "Iterator.remove()" implies this: http://java.sun.com/javase/6/docs/api/java/util/Iterator.html#remove()
JGF1 (322) [Avatar] Offline
#2
Re: Section 4.4.1: Should point out Java's ability to use "iterator.remove()"
This whole point was a bit moot for me too, what with java.util.concurrent package. Things like CopyOnWriteArrayList etc.

Forgot to mention. There's this one too:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ListIterator.html

Message was edited by:
JGF1