Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

label

 
Sireesha Mullapudi
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Why this is not giving compile time error.




here the label is not placed before any loop

Thanks
SCJP1.4
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A label can appear before other statements too. You don't have to put it at the beginning of a loop.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I added JOHN as well:


I think, break JACK; is ok, because JACK belongs to the while loop.
both break JILL; and break JOHN; won't compile.

Yours,
Bu.
 
prashanth kumar
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>I think, break JACK; is ok, because JACK belongs to the while loop.
>>both break JILL; and break JOHN; won't compile.

I tried this code and everything will compile...The compiler will throw an error only when a reference is made to a label with a BREAK statement.
Else the code will compile even though LABEL is placed in NON-LOOP places.

Rgds
Prashanth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic