title: ConcurrentModificationException With ArrayList.iterator()
body: <p>I have some code. It used to be like this, </p>
  
  <pre><code>for(Shape s: shapes){
  g.setColor(Color.blue);
      g.fill(sh);
      g.setColor(Color.gray);
      g.draw(sh);
  }
  </code></pre>
  
  <p>but it threw a ConcurrentModificationException, so I changed it to use iterators like this,</p>
  
  <pre><code>Iterator&lt;Shape&gt; s = shapes.iterator();
  while(s.hasNext()){
  Shape sh = s.next();
  g.setColor(Color.blue);
      g.fill(s);
      g.setColor(Color.gray);
      g.draw(s);
  }
  </code></pre>
  
  <p>but it still throws a ConcurrentModificationException. Maybe it's because it gets called in the paint method, but that's because it is when it gets drawn.</p>