Language syntax

Java labeled break

Exit an enclosing labeled statement, including an outer loop. Use an existing enclosing label.

Formal Syntax & Structure

java syntaxjava
break label;

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        outer:        for (int row = 0; row < 2; row++) {            for (int col = 0; col < 2; col++) {                System.out.println(row + ":" + col);                if (col == 1) { break outer; }            }        }    }}
Java Reference