The continue keyword in Java programming language
- Home
- Continue statements
- The continue keyword in Java programming language
- On
- By
- 0 Comment
- Categories: Continue statements, Keyword in Java
The continue keyword in Java programming language
The continue keyword in Java programming language
We will describe about the continue keyword in Java programming language
continue is used to skip execution (rest of loop)of a current iteration in a for loop or a while loop or do-while loop followed by advancement to the next iteration.
Syntax
Syntax of the continue keyword
for(i=0; i<max; i++) { <statements> if(done with this part) { //optional continue; } //rest of loop statement <statement> }
Example for continue keyword
public class Continue_Keyword{ public static void main(String args[]){ for (int i=0; i<=5; i++) { if (i==3) { continue; //continue keyword } System.out.print(i+" "); } } }
When the above code is compiled and executed, it will produce the following result
1 2 4 5
When using the break statements, the flow of control completely exits from the loop. continue statement ends the current iteration and jumps to the next iteration of the loop.
There are other Java language keywords that are similar to the this keyword
Suggested for you
Continue statement in C language
break statement in Python
Java language Keywords
C++ language Keywords