• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

confusing answer

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused by this answer in JQ+ concerning labeled breaks:

A break statement with label Identifier attempts to transfer control to the enclosing labeled statement that has the same Identifier as its label; this statement, which is called the break target, then immediately completes normally. In this case, the break target need not be a while, do, for, or switch statement.

I'm not sure what they are saying here. I've used breaks in switches, and in loops but have never seen a break target not be a while, do, for, or switch statement with or without a label. Can someone show me an example of this? Or maybe I'm just totally missing what this quote is all about.
Thanks for the help.
Rick
 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Rick..I am confused now..
Can any one clear our doubts? what does the statement is trying to say?..
I guess Rick is missing something..not sure.
Any Comments, Ranchers?.
Sonir
 
Rick Reumann
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like they are saying you could place a label anywhere in your program and break to it, although I can't seem to duplicate nor have I ever even seen it or heard of it before.

[ February 01, 2002: Message edited by: Rick Reumann ]
 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
It means that you can use break without loops or switch. but when u are using it without loops or switch then u must give it label i.e.
{
// codes
break;
}
this will give compile error ... though it looks like it should come out of that block.
label01: {
// codes
break label01;
}
this will compile and works fine ..
CMIW
HTH
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic