|
This example illustrates how to create the do-while loop in java.
In some conditions, you need to run some statements and processes once at least. For that you have to use the do while loop. It is same as the while loop statement but while loop first checks the certain condition and if condition is true then statements or processes are executed otherwise all the statements written under the while loop is ignored by the interpreter but do - while loop executes all the statements first at once and then check the condition if the condition is true then all the statements are also executed in second time otherwise second time ignored all the statements.
Source Code of dowhileloop.java
class dowhileloop{
public static void main(String[] args){
int a= 80;
int i=Integer.parseInt(args[0]);
do{
System.out.println("the value of: "+a);
i++;
}while(i<9);
}
}
|
|
|