2

I just wanted to know all other codes on which java labels can be applied. I only know that labels can be applied on loops.

In Kathie Sierra It was written that:-

Although many statements in a java program can be labeled, it's most common to use labels with loop statements...

From Link: Can a label block be used without loop

I get reference that label can be applied on blocks or can be used with single statement like :
hello: break hello;

Still question is can we apply label on any statement or block...

label1:int a=3;   //ERROR
label1:{int a=3; }  //legal

Why??

Community
  • 1
  • 1
Sukhbir
  • 553
  • 8
  • 23
  • 1
    This is not a duplicate of the question noted. The other question asks if there are *any* uses of `label` besides loops, whereas this question asks for *all* uses of `label`. – Sam Estep Jul 11 '15 at 14:11
  • @RedRoboHood-Actually, those answers cover almost all the cases. I traversed each one of them to ensure this. SO, Oli Sir has done a good job. – Am_I_Helpful Jul 11 '15 at 14:15
  • @shekharsuman Needing to go through all the answers to find *almost* all of the use cases is not enough. It does not answer this question. – Sam Estep Jul 11 '15 at 14:21

0 Answers0