Java Reference
In-Depth Information
Syntax:
While ( Boolean_expression)
{
//body of the While Loop
}
If the Boolean expression is true then the body defined for the While loop is executed and
this repeat execution for same body continues until the Boolean expression is evaluated to
false.
As the loop terminates or the Boolean-expression is false , the control is transferred to the
first statement following the while loop.
Example:
For the last given example of for loop , corresponding While Loop is given below.
public class Demo1 {
public static void main(String args[]) {
int a= 10;
while( a < 20 ) {
System.out.print("value of a : " + a);
a++;
}
}
}
The do...while Loop
Search WWH ::




Custom Search