Java Reference
In-Depth Information
This loop is similar to other loops with a major difference that this loop is always executed
at least once while the other for and While loops are executed only when condition or
Boolean expression is true. For and while loop may be executed for Zero times if the
condition is false.
//body for the loop
}while ( Boolean_expression);
Since this loop has the testing condition at the end of loop , the loop is executed at least
once always.
The execution of this loop is otherwise very similar to While loop. Firstly loop is executed
and then boolen_expression is evaluated. If expression is true then loop is executed again
and again until the Boolean expression is false.
Similar program for printing value of a from 10 to 19 using do….. while loop is given
public class demo2 {
public static void main(String args[]){
int a = 10;
System.out.print("value of a : " + a );
Search WWH ::

Custom Search