Syntax
while (expression) {BLOCK}
Parameters
Parameter
|
Definition
|
---|---|
expression | A statement whose evaluation returns either true or false |
BLOCK | one or more statements that execute repeatedly as long as expression evaluates to true |
Description
The while loop executes statements as long as expression is true
Example
x=1 while (x <= 5) { println("x=", x) x++ }