C continue keyword

Sometimes there is a situation in the program where we want to take control to the beginning of the loop, bypassing the statements inside the loop, which have not yet been executed. The keyword continue allows us to do this. The continue statement skip the present iteration or true expression and jumps to next iteration. Generally continue keyword cannot use with control statement (if, if-else, switch). It is used in loops.

Let’s see an example to demonstrate the use of continue

Output:

Here in above example, the condition i == 3 is satisfied then also it gets skipped. Because of keyword continue.

continue keyword with while

Output:

 

Output:

Ankit Wasankar

Senior Java Developer
Java 11 | Microservices | Reactjs | SQL

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.