Java Loops Do While - thelastmile/FreeCodeCamp GitHub Wiki

Java do..while Loop

The do..while loop is a special case of the while loop wherein the group of statements is guranteed to run atleast once before checking for a given condition. Confused? Ok, the follwing example should clear things up.

Can you guess the output of the following code snippet?

int i=10;
do{
    System.out.println("The value of i is " + i);
    i--;
}while( i >= 10 );

Remember : The condition of a do-while loop is checked After the code body is executed once.

Now that you have some idea of basic syntax, let's delve into some of the most relevant and commonly used data types which will help you to develop programs in Java.

Previous