File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "confused about labled break" Watch "confused about labled break" New topic
Author

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;

for2:
for(int i=0;i<5;i++){
System.out.println("ffff");}
}


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: http://aspose.com/file-tools
 
subject: confused about labled break
 
Similar Threads
K&B on labeled break
Label association doubt
K&B SCJP5 Reconcile of ExamWatches
K&B Exam Watch - break & continue
Continue Label Question