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 !!

Leave a Reply

Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial