The Continue Statement in Java

This guide is all about the use of continue statements in Java. What is it? How does it work? When do you need to use this statement? All of this is explained in this short guide. Let’s dive in.

the continue Statement in Java

You will use the continue statement in loops mostly. This statement in Java works somewhat like a break statement. The only difference is that it does not terminate the loop. Instead, it makes the loop run its next iteration without running the code below the continue statement. Take a look at the code snippet we provided below.

public class Main {
    public static void main(String args[]) {
        for (int i=0; i<100; i++){
            continue;     //  SKip the Iteration If Number IS Odd;
           System.out.print(i +", ");

What will be the outcome of the code? Will it print any odd number? The answer is NO. Because inside the condition, there’s a continue statement which will jump the loop to its next iteration while skipping the whole code down below.

Write for us
DelftStack articles are written by software geeks like you. If you also would like to contribute to DelftStack by writing paid articles, you can check the write for us page.

Related Article - Java Statement

  • Difference Between break and continue Statements in Java
  • Java One Line if Statement