Which statements in Java cannot be labelled? I see,
Doesn't compile. I understand that labelling such statements doesn't make sense but in mock exams I have missed such questions because I don't clearly know what is the logic behind "which kind of statements can be labelled and which cannot be. And what is the reasoning behind it."
During real development labelling statements like int 1 = 10; wouldn't be in wildest of my thoughts though. But for exam it seems like this is important to know.
Many thanks in advance.
Write your code as if the person who maintains it is a homicidal maniac who knows where you live.
Labeled statements are used in conjunction with break and continue and should appear just before the loop (for, while) when used with continue and can also appear just before a switch statement in case of break
knowledge is the difference between drudgery and strategic action -- tiny ad