aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes sample on illegal use of labeled continue and break Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "sample on illegal use of labeled continue and break" Watch "sample on illegal use of labeled continue and break" New topic
Author

sample on illegal use of labeled continue and break

Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 153
(Sorry I forgot to quote my source. Anyway, I'm posting it now. )

This is from Chapter 5 (p. 344) of the K&B Book:


Labeled continue and break statements must be inside the loop that has the same label name; otherwise, the code will not compile.


I'm a little lost on this statement. Can anyone give a sample regarding the statement? I'm trying to make my sample code not compile but it compiles fine if I use two different labels - outer and inner.

This program is an exercise from the same page, modified a little for my own experimentation.



Thank you very much in advance!

[ June 25, 2008: Message edited by: Denise Saulon ]

[ June 25, 2008: Message edited by: Denise Saulon ]
[ June 25, 2008: Message edited by: Denise Saulon ]

SCJP/OCPJP 6 | SCWCD/OCPJWCD 5 | OCPJBCD in progress
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9939
    
    6

I think they mean something like this:


Note that my "continue inner" is outside of the loop defined by the label "inner".
[ June 25, 2008: Message edited by: fred rosenberger ]

Never ascribe to malice that which can be adequately explained by stupidity.
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12907
    
    3

Denise, when you copy a question from a book or mock exam, we require that you quote your sources. So, please tell us where you copied it from.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 153
Got it! Thank you very much for the reply!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sample on illegal use of labeled continue and break
 
Similar Threads
Doubt in Rule Roundup Answer: catch block Exception Order
why the below highlighted line is not showing unreachable compile error.
Infinite loop
Puzzling question
Final's Puzzle