You use a while statement to run a statement repeatedly while some condition is true. The syntax of a while statement is as follows:
while ( booleanExpression ) statement
The Boolean expression is evaluated, and if it is true, the statement runs and then the Boolean expression is evaluated again. If the expression is still true, the statement is repeated and then the Boolean expression is evaluated again. This process continues until the Boolean expression evaluates to false, when the while statement exits. Execution then continues with the first statement after the while statement. A while statement shares many syntactic similarities with an if statement (in fact, the syntax is identical except for the keyword):
The expression ...