Labels Flashcards

1
Q

What are the scope of these two labels?

void crazyLoop(){
   int c = 0;
   JACK: while (c < 8){
       JILL: System.out.println(c);
       if (c > 3) break JILL; else c++;
   }
}
A

Jack - the while loop
Jill - the end of the print ln statement
It will not compile. If changed to just “break” or “break JACK” it will work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly