Professional Documents
Culture Documents
While Loop
While Loop
6 While loop
Java while loop is used to execute statement(s) until a condition holds true.
SYNTAX
while (condition(s)) {
// statements
}
If the condition holds true then the body of loop is executed, after execution of
loop body condition is tested again and if the condition is true then body of loop
is executed again and the process repeats until condition becomes false.
Loop body is executed till value of a is greater than value of b and c is not equal
to zero.
It is recommended to use braces always to make your program easily readable and
understandable.