• Post Reply Bookmark Topic Watch Topic
  • New Topic

clarification: break and continue  RSS feed

 
Fendel Coulptz
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) if i have some nested loops, if i put a "break;" inside one the nested loops, the inner loop concerned is "exited", and the outer loops resume. right?

2) as for the "continue;" keyword, it skips the rest of the statements after the "continue;" line and gets on with the next iteration of the SAME loop. correct?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, and yes.

Java has this nifty, easy-to-abuse feature called the "labeled break" and "labeled continue". You can add a label to a loop, and then specify that label in a break or continue inside that loop or any loop nested inside; if you do, then that break or continue will apply to that labelled loop, not necessarily the one that contains the break or continue -- i.e.,



Of course, if I find the varmint whut wrote that there code, I'll string 'im up by the thumbs.
 
Fendel Coulptz
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah, what does the code do?
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As written the code will not compile as the if statement returns a long instead of a boolean. If you change the if statement to read
Then it would turn you computer into a useless piece of junk which writes TICK to the screen in an endless loop
[ September 28, 2004: Message edited by: Nigel Browne ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!