Java Continue

The continue statement is used in loop control structure when you need to jump to the next iteration of the loop immediately. It can be used with for loop or while loop.

The Java continue statement is used to continue the loop. It continues the current flow of the program and skips the remaining code at the specified condition. In case of an inner loop, it continues the inner loop only.

We can use Java continue statement in all types of loops such as for loop, while loop and do-while loop.

Syntax:

continue;

Example :

import java.util.*;

public class Main {
public static void main(String[] args) {

for (int i = 0; i <= 7; i++) {
if (i == 6) {
continue;
}
System.out.println("A Number is : "+i);
}
}
}

Output :

A Number is : 0
A Number is : 1
A Number is : 2
A Number is : 3
A Number is : 4
A Number is : 5
A Number is : 7

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

60657