continue in while loop java code example
Example 1: java how to continue outer loop
public class Test {
public static void main(String[] args) {
outerloop:
for (int i=0; i < 5; i++) {
for (int j=0; j < 5; j++) {
if (i * j > 6) {
System.out.println("Breaking");
break outerloop;
}
System.out.println(i + " " + j);
}
}
System.out.println("Done");
}
}
Example 2: continue in java
int i=0;
while(i<10){
if(i%2==0){
i++;
continue;
}
System.out.println(i);
i++;
}
Example 3: continue in java
int i = 0;
while (i < 10) {
if (i == 4) {
i++;
continue;
}
System.out.println(i);
i++;
}