Construction. while loops

[comp1110-0Q]

Loops are a way for control flow to repeat:

int i = 0; while (i < 10) { IO.println("i < 10 is still true!"); i = i + 1; }

The above code will print the message 10 times total, because in each iteration, the variable i (which starts at 0) is increased by one, until it reaches 10, when the loop will exit as the guard (i < 10) is false.

bars magnifying-glass caret-down plus minus arrow-right xmark