> For the complete documentation index, see [llms.txt](https://gyansetu-java.gitbook.io/core-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-java.gitbook.io/core-java/flow-control/do-while-loop.md).

# Do While loop

A do-while loop is used to repeatedly execute a set of statements until the condition that it uses evaluates to false.

&#x20;**This loop checks the condition after it completes the execution of all the statements in its loop body.**

![](/files/-LTWTFWhO_n8hqwlokiF)

![](/files/-LTWTWDDoqpA0wHRMG_l)

#### Example 1: Program to print line 10 times

```java
package com.test.test1;

public class DoWhileEx {
	public static void main(String[] args) {
		int x = 1;
		do {
			System.out.println("Line : "+x);
			x++;
		} while (x <= 10);
	}

}
```

```
Line : 1
Line : 2
Line : 3
Line : 4
Line : 5
Line : 6
Line : 7
Line : 8
Line : 9
Line : 10
```

#### While Vs Do-while loop :

![](/files/-LTWXI5__QSQNgGV1IIK)

#### Problems:

Try all the examples as well as problems with while loop which are mentioned in [for loop](/core-java/flow-control/for-loop.md) section.
