Rewriting for Loops as while Loops

The same loop, two ways
A thermostat lowers its set point overnight, from 72 degrees down to 60, by 4 degrees at a time.
for (int setting = 72; setting >= 60; setting = setting - 4)
{
System.out.println(setting);
}
This prints 72, 68, 64, and 60. The update then makes setting 56, which fails setting >= 60. The same loop written with while puts each part of the header in the place where it runs.
int setting = 72;
while (setting >= 60)
{
System.out.println(setting);
setting = setting - 4;
}
The initialization becomes a statement before the loop, so it runs once. The Boolean expression becomes the while condition, checked before each pass. The update becomes the final statement inside the braces, after the print. A while loop with a counter can be turned into a for loop by the same steps in reverse.
Where the update goes
In the while version, the update has to come after the print. Placed first, it lowers the setting before the print, so the loop prints 68, 64, 60, and 56. Left out completely, the update never changes setting, and the loop prints 72 forever.
Bounds
The comparison and the number in the Boolean expression decide where the loop stops. With setting > 60 the loop prints 72, 68, and 64, since 60 no longer passes. When the step isn't 1, trace the values rather than guess. From 72 by 5 degrees with setting >= 60, the values are 72, 67, and 62, and the loop stops at 57 without ever reaching 60.
A header can also give a body zero passes. In for (int setting = 58; setting >= 60; setting = setting - 4), the first evaluation is 58 >= 60, which is false.
Two surprises
A semicolon directly following a loop header ends the loop there, and its body becomes the empty statement.
int setting = 72;
while (setting >= 60);
{
System.out.println(setting);
setting = setting - 4;
}
This compiles, and it never finishes. The loop repeats the empty statement, which changes nothing, so setting >= 60 stays true. That braced block isn't the loop's body, and the program never reaches it. A semicolon after a for header ends that loop the same way.
A statement in the body that changes the loop control variable runs as well as the update. With setting = setting - 4; also written in the body after the print, each pass lowers the setting by 8 degrees, and the loop prints only 72 and 64.