A blog for computer science passionates.

Tuesday 19 May 2020

Java: Flow Breaking Statements (Jumping Statements) Part-2

Hello Freinds!!!
Welcome to passionforcs,

In this article, we are going to learn one more flow breaking (jumping) statement i.e. continue. continue statement is another flow breaking statement.
continue statement skips an iteration, when continue occurs control directly transfers to the condition for the next iteration.
How Continue Statement Works?
In the above example, we can see that when the value of i divides by 2 and gets the reminder 0, continues the loop i.e. skips that iteration otherwise it prints the value of i. when the value of i equals 6 the loop terminates and at last it prints Bye...Bye...

We have one more form of continue statement i.e. continue with label. same as break with label. For example,


In the above example the values of i and j multiplied only for odd numbers when for even numbers it skips the iteration. Try these examples to get more clarity. Happy Coding... :)

No comments:

Post a Comment