Java Zero to All All questionsPractise free
Interview questions › Java Foundations — Zero to Basics › Control Flow — Loops, Conditionals & Switch

What is the difference between break, labeled break, and continue, and when is a labeled break actually justified?

Level II · JuniorControl Flow — Loops, Conditionals & Switch
Short answer

break exits the innermost loop or switch, continue skips to the next iteration of the innermost loop, and a labeled break/continue targets a named outer loop.

Explanation

A labeled break is justified for cleanly exiting nested loops once a condition is met — for example, found a match in a 2D grid — without a found flag or refactoring into a method. In practice extracting the loop into a method and returning is often cleaner and is what I'd prefer in shared code.

Common mistakes
  • Overusing labeled breaks instead of extracting a method.
  • Confusing break (leave loop) with continue (skip to next iteration).

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for Control Flow — Loops, Conditionals & Switch.

Practise free

More on Control Flow — Loops, Conditionals & Switch