Regarding getting error in retrieving the list
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/11828639/regarding-concurrent-modification-exception">Regarding concurrent modification Exception</a>  </p>
</blockquote>



<p>I am getting this concurrent modification exception error in the below code as I am trying to remove the elements while iterating ..the code is below..</p>

<pre><code> List  list=new ArrayList ();
          list.add(new Emp("Saral","Trainer",34500));
          list.add(new Emp("Saral","Trainer",36000));
          list.add(new Emp("Saral","Trainer",33000));
          list.add(new Emp("Sachin","Programmer",24000));
</code></pre>

<p>and the way I am retrieving is ..</p>

<pre><code>System.out.println("Content of list are : ");
          ListIterator itr1=list.listIterator();
          while(itr1.hasNext())
          {
              list.add(new Emp("Anand","Manager",56000)); //
            Emp e=(Emp)itr1.next();  
            e.display();
          }
</code></pre>

<p>Could you please advise how this error can be avoided..?</p>
