# while Loop

*noun*

say it: **“WHILE loop”** **/ˈwaɪl lup/**

A loop that keeps repeating its code for as long as a condition stays true, checking the condition before each pass.

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

**while Loop** — A loop that repeats while its condition remains true.

```java
class Counter {
    int countToThree() {
        int number = 0;

        while (number < 3) {
            number++;
        }

        return number;
    }
}
```

## In a sentence

- “The game runs in a **while loop** until the player has no lives left.”

Level: Apprentice · [More Java terms at this level](https://www.ask-codey.com/glossary?category=java&level=2)

Updated: October 26, 2026

## In other subjects

- [while Loop in C#](https://www.ask-codey.com/glossary/while-loop-c-sharp)
- [while Loop in JavaScript](https://www.ask-codey.com/glossary/while-loop-javascript)
- [while Loop in PowerShell](https://www.ask-codey.com/glossary/while-loop-powershell)
- [while Loop in Python](https://www.ask-codey.com/glossary/while-loop)
- [while Loop in Unix](https://www.ask-codey.com/glossary/while-loop-unix)

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