While
While Loops repetitively execute a block of code as long as a specified condition is true.
For example, the loop in this example will repetitively execute its block of code as long as the variable i is less than 5:
The Do/While Loop is a variant of the while loop. This loop will execute the code block once before checking if the condition is true. It then repeats the loop as long as the condition is true:
Note: Be careful to avoid infinite looping if the condition is always true!
Last updated