outer: for(int i = 0; i < 5; i++) {
for(int j = 0; j < 20; j++) {
System.out.print("*");
brack outer;
}
System.out.println();
}
//this will only print one star
class LabeledBreak {
public static void main(String[] args) {
// the for loop is labeled as first
first:
for( int i = 1; i < 5; i++) {
// the for loop is labeled as second
second:
for(int j = 1; j < 3; j ++ ) {
System.out.println("i = " + i + "; j = " +j);
// the break statement breaks the first for loop
if ( i == 2)
break first;
}
}
}
}