while loop: It repeats a statement until the controlling expression becomes false.
Note: Controlling expression can be of any Boolean type.
Note: While loop body can be empty, that can be seen in the example given below.
while (controlling-expression)
{
// body of the loop, statements to be executed
}
The do/while loop is a modification of the while loop in java. The loop will perform the piece of code once before verifying if the condition goes right or evaluates to true, then it will replicate the loop as long as the condition goes right and evaluates to true.
do {
// body of the loop, it will be executed at least once
} while (condition-expression);
This loop indicates that it will become an infinite while loop if you pass true in the while loop.
In this, you need to press ctrl+c to exit from the code.
Knowledge2life
Knowledge2life
Knowledge2life
Knowledge2life
Knowledge2life
|