Hi everyone, Can someone, please, explain me why I have a running error with this code :
the error is :
Exception in thread "main" java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(Unknown Source) at java.util.AbstractList$Itr.next(Unknown Source) at Test.main(Test.java:21)
Thank you for your help.
Edit by mw: Fixed code tags. (Tags in these forums use square brackets  instead of angled brackets.) [ June 20, 2007: Message edited by: marc weber ]
According to the API for ConcurrentModificationException...
This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible.
...if a thread modifies a collection directly while it is iterating over the collection with a fail-fast iterator, the iterator will throw this exception.
Basically, the exception is thrown because you're modifying the collection (adding new elements) after you get the iterator but before you use the iterator. In general, it's best to create the iterator immediately before using it -- as you do in your commented line.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org