The do…while Loop in Java
A do…while loop is similar to the while looping construct aside from that a do…while circle is ensured to execute no less than one time. The syntax for this looping construct is as follows:
do {
/Statements
}while(<booleanexpression>);
Perceive that the Boolean declaration shows up toward the end of the circle, so the code execute once before the Boolean is tried. In the event that the Boolean declaration is genuine, the stream of control bounced go down to do, and the code execute once more. This methodology rehashes until the Boolean articulation is false.
Sample implementation:
public class myTest {
public static void main(string args[]){
int i = 1;
do{
System.out.print(āi = ā + i );
i++; System.out.print(ā\nā);}while( i<1 );
}
This would create the accompanying result:
i = 1