• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

clarification: break and continue

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ah, what does the code do?
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Nothing? Or something? Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic