title: getting rid of concurrent modification exception
body: <p>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</p>
  
  <p>ArrayList "Errors" is already populated.</p>
  
  <pre><code>ArrayList&lt;MainErrorObject&gt; errors;
  ArrayList&lt;MainErrorObject&gt; newList;
  
  for (MainErrorObject current : errors)
  {
     newList = processErrorObjects(current);
     errors.addall(newList);
  }
  </code></pre>
  
  <p>When i try to execute the code above, i get the concurrentmodification exception. please help me in resolving this.</p>
  
  <p>Thanks in advance.</p>