All for-loops I've seen basically look like the following:
for(int i = 0; i < thing.length; i++){
// Does this each iteration
}
But working on a project I came across (what I assume is) a different type of for-loop shown below. Can someone explain to me how this type of loop works? Does it have a name?
Component[] squares = getComponents();
for (Component c : squares)
{
Square s = (Square) c;
// Set the color of the squares appropriately
int status = model.getOccupant(s.getRow(), s.getCol());
if (status == P1)
{
s.setColor(P1_COLOR);
}
else
{
s.setColor(BACKGROUND_COLOR);
}
}