jump-statement;
continue;
Example {
public static void main(String[] args) {
//for loop
for(int i=1;i<=10;i++){
if(i==5){
//using continue statement continue;
//it will skip the rest statement }
System.out.println(i);
}
}
}
1
2
3
4
6
7
8
9
10
public static void main(String[] args) {
// outer loop
for(int i=1;i<=3;i++){
//inner loop
for(int j=1;j<=3;j++){
if(i==2&&j==2){
//using continue statement inside inner loop continue;
}
System.out.println(i+" "+j);
}
}
}
1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 3
public class
continueExample3 {
public static
void main(String[] args) {
aa: for(int i=1;i<=3;i++){
bb: for(int j=1;j<=3;j++){
if(i==2&&j==2){
//using continue statement with label continue aa;
}
System.out.println(i+" "+j);
}
}
}
}
1 1
1 2
1 3
2 1
3 1
3 2
3 3
WhileExample {
public static void main(String[] args) {
//while loop int i=1;
while(i<=10){
if(i==5){
//using continue statement i++;
continue;
//it will skip the rest statement }
System.out.println(i);
i++;
}
}
}
1
2
3
4
6
7
8
9
10
continueDoWhileExample {
public static
void main(String[] args) {
//declaring variable int i=1;
//do-
while loop do{
if(i==5){
//using
continue statement i++;
continue;
//it will skip the
rest statement }
System.
out.println(i);
i++;
}
while(i<=10);
}
}
1
2
3
4
6
7
8
9
10