# do-while Loop

A loop that runs its body once before checking whether to repeat.

## What is **do-while Loop** in Java?

**do-while Loop** — A loop that runs its body once before checking whether to repeat.

```java
class Login {
    int makeOneAttempt() {
        int attempts = 0;

        do {
            attempts++;
        } while (attempts < 1);

        return attempts;
    }
}
```

Level: Apprentice · [More Java terms at this level](https://www.ask-codey.com/glossary/subjects/java/apprentice)

Updated: September 27, 2026

## In other subjects

- [do-while Loop in C#](https://www.ask-codey.com/glossary/do-while-loop-c-sharp)

Source: https://www.ask-codey.com/glossary/do-while-loop
