Java continue Keyword

After learning break statements, lets quickly recap about another important keyword “continue” in java. In one sentence, the continue statement skips the current iteration of a for loop, while loop, or do-while loop.

Let’s go deeper into continue statements. A continue statement can only be used inside the for-loop, while-loop, and do-while statements.

There are two forms of the continue Statements:

  • Unlabeled continue statement
  • Labeled continue statement

The unlabeled form skips to the end of the innermost loop’s body and evaluates the boolean expression that controls the loop. In more general terms, continue skips the statements after the continue statement and keeps looping.

On the other hand, a labeled continue statement skips the current iteration of an outer loop marked with the given label.

Let’s look at one example to get more understanding of continue statements in java.

public static void main( String [] args ) {

       for( int i = 0 ; i < 10 ; i++ )

             if( i % 2 == 0) 
                 continue;		//if i is even, skip the print statement

             System.out.println("The number is " + i );


The number is 1
The number is 3
The number is 5
The number is 7
The number is 9

That’s all for this another important keyword “continue” in java.

Happy Learning !!

Was this post helpful?

Join 7000+ Awesome Developers

Get the latest updates from industry, awesome resources, blog updates and much more.

* We do not spam !!

Leave a Comment


A blog about Java and related technologies, the best practices, algorithms, and interview questions.