# break

A statement that immediately exits the nearest loop or switch.

## What does **break** do in Java?

**break** — A statement that immediately exits the nearest loop or switch.

```java
class NumberFinder {
    int firstOddNumber(int[] numbers) {
        for (int number : numbers) {
            if (number % 2 == 0) {
                continue;
            }

            return number;
        }

        return -1;
    }
}
```

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

Updated: September 27, 2026

## In other subjects

- [break in C#](https://www.ask-codey.com/glossary/break-c-sharp)
- [break in JavaScript](https://www.ask-codey.com/glossary/break-javascript)

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