File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes confused about labled break 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 "confused about labled break" Watch "confused about labled break" New topic

confused about labled break

saied ims
Ranch Hand

Joined: Jun 21, 2005
Posts: 109
in exam watch :
Remember, continue statements must be inside a loop; otherwise,
you�ll get a compiler error. break statements must be used inside either a loop orswitch statement. (Note: this does not apply to labeled break statements.).

in another eexam watch:
"Labeled continue and break statements must be inside the loop that
has the same label name; otherwise, the code will not compile."

HOW come??? can anybody told me any explain about the first note??
class D{

public static void main(String [] ism){
int f=0;

for(int i=0;i<5;i++){

void fool(){
break for2;}

this is wont compile sure but ,why the first exam watch wrote "Note: this does not apply to labeled break statements.)"

thanks all
[ August 16, 2006: Message edited by: saied ims ]
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
Why label statement causes compile time error?:

If a break statement has a label it must be the label of an enclosing statement.

Here is an example:
I agree. Here's the link:
subject: confused about labled break
It's not a secret anymore!