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 {

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;
System.out.print(“i = ” + i );
i++; System.out.print(“\n”);}while( i<1 );

This would create the accompanying result:

i = 1

For any query or issue, feel free to discuss on