Introduction to Java · Introduction to Java Programming

Break Statement

Watch lectures

Break Statement

1. What It Does (beginner)

break = exit the nearest loop or switch immediately. Like emergency exit: skip rest, jump out.

// USE 1: stop loop early (search!)
for (int i = 0; i < 10; i++) {
    if (i == 3) break; // exit loop at 3
    System.out.print(i + " "); // 0 1 2 (3 never prints!)
}
// USE 2: stop switch fall-through (see Switch topic)
switch (day) { case 1: System.out.println("Mon"); break; /* ... */ }

Plain break exits inner only; break outer exits labelled outer.

4. Traps

  • break outside loop/switch = ERROR.
  • In nested loops, plain break exits one level (exam asks "which loop exits?").

5. Exam Points

  • Search-loop + switch break — 3-5 marks, frequent.
  • Labelled vs plain output trace — 3-5 marks, frequent trap.
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Introduction to Java Programming modules