< Prev
Next >

Continue Statement

In Java, we may use continue statement within a loop and when a continue statement is encountered in a loop of a program in execution, it skips executing the rest of statements in the loop for that particular iteration and the program continues with the next iteration and condition checking in the loop.

Continue statement example

//continue statement example

public class ContinueEx
public static void main(String... ar)

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

	System.out.println("i ="+i);

System.out.println("Out of the loop");

} //main method ends

} //class ends


Out of the loop

As you may see in the output of the program, when continue statement was encountered within an executing for loop, it skipped executing the System.out.println() statement in the loop for that particular iteration i.e. when i is equal to 2. The program continued normally with the next iteration(i is equal to 3) and condition checking.

Please share this article -

Facebook Google Pinterest Reddit Tumblr Twitter

< Prev
Next >
< Break Statement
Labelled Break Statement>

Please Subscribe

Please subscribe to our social media channels for daily updates.

Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page


Please check our latest addition