This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Trying to understand labeled 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 "Trying to understand labeled "break" with for loops" Watch "Trying to understand labeled "break" with for loops" New topic
Author

Trying to understand labeled "break" with for loops

Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
Hello Ranchers!
I am trying to understand the labeled break with for loops and I wrote a code to try out various things in terms of where the control is actually transfered to from the labeled break statements.
My conclusion is: Labeled break is only useful in the nested loop situations.
Am I correct? I need your feedback.
Also, please check out the following code. It seems that the comiler is unable to detect/catch a unreachable statement.

CTE- Stands for Compile Time Error
prt method is taken from Bruce Eckel's book.
Looking forward to your input,
If you happen to have a good resource besides the JLS for labeled break/continue statements could you please post them?
Thanks,
Brian
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
in the Java tutorial there may be something useful too:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html
HIH


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
Thanks Valentin!
Ranchers - Any thoughts on the uncaught unreachable statement by the compiler?
Brian
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to understand labeled "break" with for loops
 
Similar Threads
Use of labelled statement in java ?
Loop..continue...break
about Continue pls explain me
Loop
difference between continue and break