aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confusing answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confusing answer" Watch "confusing answer" New topic
Author

confusing answer

Rick Reumann
Ranch Hand

Joined: Apr 03, 2001
Posts: 281
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
sonir shah
Ranch Hand

Joined: Nov 01, 2001
Posts: 435
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

Joined: Apr 03, 2001
Posts: 281
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 ]
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
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


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusing answer