Do-While is a special kind of loops. In this loop "While" does not have any body but "Do" does have. This means when the loop is executed the execution first goes to the "Do" block and then it goes to the "While" to check the condition or expression. This makes the Do-While loop run once even if the condition results in false and this makes this loop special.
public class Do_While
{
public static void main(String[] args)
{
int var = 1;
do
{
System.out.println(var);
var++;
}while(var <= 10);
}
}
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment