getting rid of concurrent modification exception
i have a small problem in java. I am trying to loop through an ArrayList
and add more items to the same arraylist during the looping and am getting
concurrentModificationexception. what are the work-around for this
problem, my code is like this
ArrayList "Errors" is already populated.
ArrayList < MainErrorObject > Errors;
ArrayList < MainErrorObject > newList;
MainErrorObject meObject=null;
for( meObject : Errors )
{
newList = processErrorObjects();
Errors.addall(newList);
}
When i try to execute the code above, i get the concurrentmodification
exception. please help me in resolving this.
Thanks in advance.
No comments:
Post a Comment