What is wrong with this foreach loop..??? Android
<p>I have a foreach loop iterating through each object in a vector. When I debug the code, it runs successfully for the first object in the vector. But then it will fail when it tries to run the loop for the second object. I am <em>sure</em> there is more than one element in the vector.</p>

<pre><code>for(Object shape : vecForShapes)
        {
            currentNode = (Drawable) shape;
             newNode = getResources().getDrawable(R.drawable.nodered);
             newNode.setBounds(currentNode.getBounds());
             vecForShapes.remove(currentNode);
              vecForShapes.add(newNode);
        }   
</code></pre>

<p>So basically my question is, why is this loop failing? I really do not understand what is wrong here.</p>

<p>P.S. My final aim is to remove <code>currentNode</code> from the vector, replace it with <code>newNode</code> then redraw the whole vector in my <code>onDraw</code> method.</p>

<p>Thanks</p>
