Can someone tell me why the compiler says the label is missing in the below code:
CASE1:
Error: Label is missing
void crazyLoop() {
int c = 0;
JACK: while (c < 8) {
JILL: System.out.println(c);
if (c > 3)
break JILL;
else
c++;
}
}
Here JILL
is reachable as I am have declared JILL
inside JACK
and not outside JACK
.
CASE2:
Error: c cannot be resolved. And if I do this :
void crazyLoop() {
JILL:int c = 0;
JACK: while (c < 8) {
System.out.println(c);
if (c > 3)
break JILL;
else
c++;
}
}
the compiler says c
cannot be resolved to a variable.
Can someone please explain what is happening ?