• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sample on illegal use of labeled continue and break

 
Denise Advincula
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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 ]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Denise Advincula
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it! Thank you very much for the reply!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic