java2db

How to use while and do while loop control flow statements in java



To execute a group of statements as long as the condition is true, use while and do while loop control flow statements.

  while loop control statement :

while and do while loop This loop won’t execute if the condition is false.

while and do while loop while loop evaluates its expression at the top.

while and do while loop  do-while loop control statement :

Executes at least once even though the condition is false.

do-while evaluates its expression at the bottom of the loop instead of the top.

 

syntax :

while(condition)
{
//statements——-
——————-
——————-increment / decrement
}
do
{
//statements——-
——————-
——————increment / decrement
}while(condition);

 Example for while loop :

 Example for do-while loop :

An array manipulations using while and do-while :

Execution Result:

The while loop is also same as do..while loop, but it is more compact syntactically.




Related Posts :
PL/SQL FOR and WHILE loop controls
How to use for loop control flow statement in java
Branching or break continue and return statements in java
   [will not be published]



^ <