title: For loops in Java Swing using index
body: <p>Can someone help me point at the difference between these two for loops? They look like they might be doing the same thing, but they aren't.</p>
  
  <pre><code>        for(int i = 0; i &lt; shapes.size() - 1; i++) {
              Graphics2D g2d = (Graphics2D) g;
              shapes.get(i).paint(g2d);
          }
  </code></pre>
  
  <p>How do I write my first for loop without the i (index)?</p>
  
  <pre><code>        for(Shape shape : shapes) {
              Graphics2D g2d = (Graphics2D) g;
              shape.paint(g2d);
          }
  </code></pre>