What will be the result of attempting to compile and run the following program?
public class Main { public static void main(String[] args) { int counter = 0; l1:/*from ww w.j a va2 s. c o m*/ for (int i=0; i<10; i++) { l2: int j = 0; while (j++ < 10) { if (j > i) break l2; if (j == i) { counter++; continue l1; } } } System.out.println(counter); } }
Select the one correct answer.
(a)
The program will fail to compile since the label l2 cannot precede the declaration int j = 0.
For a label to be associated with a loop, it must immediately precede the loop construct.