my dog learned polymorphism*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
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: 160
(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 | OCMJEA in progress...
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

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 ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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: 160
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
Infinite loop
Final's Puzzle
why the below highlighted line is not showing unreachable compile error.
Doubt in Rule Roundup Answer: catch block Exception Order
Puzzling question