• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Continue statement clarification

 
Jason Attin
Ranch Hand
Posts: 232
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI guys I came across something on the OCA book, page 90.
It reads:
While the break statement transfers control to the enclosing statement, the continue statement transfers control to the boolean expression that determines if the loop should continue

Now, from experience, that's not quite accurate in the case of a for loop because the continue statement when executed transfers control to the increment or update statement whatever we want to call it, but the book doesn't make any distinction, in fact it goes ahead presenting an example with a for loop without saying that the increment is executed first and then the boolean expression is checked. I found this rather confusing, even if I've used for loops before.
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which OCA book are you referring to?
 
Narayana Bojja
Ranch Hand
Posts: 130
4
Hibernate Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason Attin,

Now, from experience, that's not quite accurate in the case of a for loop because the continue statement when executed transfers control to the increment or update statement 

Yes. I agree with your opinion for only for loop. But the author is explained for while loop.



In the above case continue statement takes the control  to the boolean condition which determines if the loop should continue.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic