Whenever you want to skip a particular iteration of the loop the continue statement is used. When you want a particular section of the code to be skipped during the current iteration we use the continue statement. One might want to continue running the loop, but stop processing the remainder of the code in its body for this particular iteration. This is in effect, a goto just pass the body of the loop, to the loop’s end. The continue statement performs such an action. In while and do-while loops a continue statement causes control to be transferred directly to the conditional expression that controls the loop. In a for loop, control goes first to the iteration portion of the for statement and then to the conditional expression. For all three loops, any intermediate code is by passed.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment