I've found the following piece of code in java.util.Calendar:
public final void clear()
{
for (int i = 0; i < fields.length; ) {
stamp[i] = fields[i] = 0; // UNSET == 0
isSet[i++] = false;
}
areAllFieldsSet = areFieldsSet = false;
isTimeSet = false;
}
I understand what it's doing and why it's working. But missing the increment and doing it at the end of the loop, it clearly differs from the "normal" for pattern (as described in http://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html)
for (initialization; termination; increment) {
statement(s)
}
Is there any advantage in the approach I've shown above?