What is the result of the following code:
public class Main { public static void main(String args[]) { one: for(int i=0; i<3; i++) { System.out.print("Pass " + i + ": "); }//from w ww. j ava 2 s . c o m for(int j=0; j<100; j++) { if(j == 10) { break one; } System.out.print(j + " "); } } }
Compile time error: The label one is missing
You cannot break to any label.
break statement can only jump to an enclosing block.
Since the loop labeled one
does not enclose the break statement, Java cannot transfer control out of that block.