Continue Statement in Java Example

Continue Statement in Java Example. A Java program to execute the continue statement. By using this program we can print the execute the continue statement in java. The continue keyword can be used in any loop control structure. It forces the loop to immediately jump to the next iteration of the loop. When the continue keyword is used in a for loop, control is immediately passed to the update statement. The continue keyword is used in a for loop or a while loop to end the current iteration and go on to the next.

public class Main
{
public static void main(String[] args)
{
for(int i=1;i<=10;i++)
{
if(i==5)
{
continue;
}
System.out.println(i);
}
}
}

1
2
3
4
6
7
8
9
10

For Loop in Java Program

In Java, a “for” loop is an entry-controlled loop that allows a user to iteratively run a block of statement(s) for a specified number of times. The test condition supplied within the “for” loop determines the number of iterations. The Java “for” loop is one of the simplest Java loops to understand. 

A for-loop (or simply for loop) is a control flow statement in computer science that specifies iteration and allows code to be performed repeatedly. Using this looping statement we can execute the continue statement in java.

If Statement in Java

The if statement in Java is the most basic decision-making statement. It is used to determine if a certain statement or block of statements will be performed or not; that is, if a given condition is true, then a block of statements is executed; otherwise, it is not executed.