Continue Statement
The continue statement is used inside a loop to skip a block of code based on a specified condition. After skipping, it continues the next iteration of the loop until the loop ends.
Flow Diagram
Source Code:
import java.util.Scanner;
public class skipEvenNumber {
public static void main(String[] args) {
Scanner input = new Scanner(System.in); //object
System.out.print("Enter number : ");
int number = input.nextInt();
for (int i = 1; i <= number; i++) {
if (i % 2 == 0) {
continue; // Skip even numbers
}
System.out.print(" "+ i); //1 3 5 7 9
}
}
}Result:
Source Code:
public class skipContinue {
public static void main(String[] args) {
for(int i=0; i<10; i++)
{
System.out.print(i + " ");
if (i%2 == 0) //skip new line 0 2 4 6 8
continue;
System.out.println(""); //new line 1 3 5 7 9
}
}
}Result:
Watch the video:
Ebook: https://softkhpc.blogspot.com/2025/05/java-programming-ebooks.html

