This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The API documentation of ConcurrentModificationException explains why: it is not allowed to change the content of a collection while you are iterating over it. That's what you are doing in the commented out line 18. You can only change the collection you're iterating over by calling methods in the iterator, such as the add method that you are calling in line 19.
I am sorry but i commented the wrong line . It was line 18 instead of 19 . And could you tell me that how exactly i make it ok ? Because when i use it1.add() , no elements are added to the collection .