Listing 3: Java program that exits a nested loop with labeled break

public class Nested2 {
    public static void main(String[] args) {
        loop1:
        for (int i = 0; i < 2; ++i) {
            for (int j = 0; j < 2; ++j) {
                for (int k = 0; k < 2; ++k) {
                    System.out.println(i + "," + j + "," + k);
                    if (k == 1)
                        break loop1;
                }
            }
        }

    }
}