java continue keyword code example
Example 1: continue in java
int i=0;
while(i<10){
if(i%2==0){
i++;
continue;
}
System.out.println(i);
i++;
}
Example 2: Continue statement in java
import java.util.*;
public class ContinueJavaExample
{
public static void main(String[] args)
{
for(int a = 1; a <= 10; a++)
{
if(a % 2 != 0)
{
continue;
}
System.out.println(a + " ");
}
}
}
Example 3: continue in java
int i = 0;
while (i < 10) {
if (i == 4) {
i++;
continue;
}
System.out.println(i);
i++;
}
Example 4: what does the continue keyword do in java
int number = 4;
int finalnum = 20;
while(number <= finalnum){
number++;
if(number %2 != 0){
continue;
}
System.out.println("Even Number!: "+ number);
}
}