Last Updated : 23 Jul, 2025
In Java, the continue statement is used inside the loops such as for, while, and do-while to skip the current iteration and move directly to the next iteration of the loop.
Example:
Java
// Java Program to illustrate the use of continue statement
public class Geeks
{
public static void main(String args[])
{
// For loop for iteration
for (int i = 0; i <=5; i++)
{
// Check condition for continue
// skip the execution of loop when i==3
if (i == 3)
continue;
System.out.print(i + " ");
}
}
}
Flow Chart
When Continue Statement Used in Java?
The continue statement is used when we want to skip a particular condition and continue the rest execution. Some Points to consider while using Continue statements are mentioned below:
In the below program, we give an example, of how to use the continue statement within the While loop.
Java
// Java Program to illustrate the use of
// continue statement inside the While loop
public class Geeks
{
public static void main(String args[])
{
int c = 0;
// While loop for iteration
while (c <= 5)
{
// Continue used when c==3
if (c == 3)
{
c++;
continue;
}
System.out.print(c + " ");
c++;
}
}
}
2. Continue Statement Inside Do While Loop
In the below program, we give an example, of how to use the continue statement within the do-While loop.
Java
// Java Program to illustrate the use of
// continue statement inside the Do-While loop
import java.util.*;
public class Geeks
{
public static void main(String[] args)
{
int i = 0;
// Do-While loop for iteration
do
{
// Continue Statement used when
// i is equal to 3
if (i == 3)
{
i++;
continue;
}
System.out.print(i+" ");
i ++;
// Condition check
} while (i <= 5);
}
}
3. Continue Statement Inside Inner Loop(Nested Loop)
In the below program, we give an example, of how to use the continue statement within Nested loops.
Java
// Java Program to illustrate the use of continue statement
// inside an inner loop or simply nested loops
import java.util.*;
public class Geeks
{
public static void main(String[] args)
{
// Outer loop for iteration
for (int i = 1; i <= 4; i++)
{
// Inner loop for iteration
for (int j = 1; j <= 3; j++)
{
// Continue statement in inner loop to
// skip the execution when i==3
if (i == 3 && j==2)
{
continue;
}
System.out.print(i+"."+j+" ");
}
System.out.println();
}
}
}
1.1 1.2 1.3 2.1 2.2 2.3 3.1 3.3 4.1 4.2 4.3Break and Continue in Java
Break and Continue are both used to control the flow of loops, each in its way. The break statement stops the loop entirely, while the continue statement skips the current iteration and proceeds with the next, allowing the rest of the loop to function as usual.
Example:
Java
// Java Program to implement continue
// And break in same loop
import java.io.*;
class Geeks
{
public static void main(String[] args)
{
for (int i = 1; i <= 10; i++)
{
// Skip condition where i==3
if (i == 3)
continue;
// Exit the loop when i == 7
if (i == 7)
break;
System.out.print(i + " ");
}
}
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4