Home Java Break Statement

Break Statement in Java

Beginner ⏱ 6 min read Updated: Jun 2026

The break statement in Java is a control flow statement used to terminate the execution of a loop or switch statement immediately. When the break statement is encountered, the program exits from the current loop and continues execution from the next statement.

The break keyword is commonly used with for loop, while loop, do while loop, and switch statement to control the flow of a Java program.

What is Break Statement in Java?

A break statement in Java is a jump statement that is used to stop the execution of a loop before its condition becomes false. It transfers the control of the program outside the loop.

In switch statements, break is used to stop the execution of a case block and prevent the execution of the following cases.

💡
Key Point: The break statement immediately exits the current loop or switch block.

Syntax of Break Statement in Java

Syntax
break;

How Break Statement Works in Java?

  • The program starts executing the loop normally.
  • When the break statement is reached, the loop stops immediately.
  • Control moves to the statement after the loop.

Break Statement Example in Java

Example
public class Main {
    public static void main(String[] args) {
        for(int i = 1 ; i <= 5; i++) {
            if(i == 3) {
                break;
            }
            System.out.println(i);
        }
   }
}
Output
1
2

Explanation of Example

In the above example, the loop starts from 1 and runs until 5. When the value of i becomes 3, the break statement executes and terminates the loop immediately.

Break Statement with While Loop

Example
int i = 1;
while(i <= 5) {
    if(i == 4) {
        break;
    }
    System.out.println(i);
    i++;
}

Break Statement in Switch Case

In a switch statement, the break keyword prevents execution from moving into the next cases after a matching case is found.

Example
int day = 1;
switch (day) {
    case 1: 
        System.out.println("Monday");
        break;
    case 2: 
        System.out.println("Tuesday");
}

Types of Break Statement in Java

Simple Break

Used to exit from the current loop or switch statement.

Labeled Break

Used to exit from a specific outer loop in nested loops.

Advantages of Break Statement

Loop Control

Provides better control over loop execution.

Saves Time

Stops unnecessary iterations after finding the required result.

Easy Logic

Makes program flow easier to manage.

When to Use Break Statement?

  • When you want to stop a loop based on a condition.
  • When searching for a specific element.
  • When you want to exit a switch case.
  • When further execution is unnecessary.