This Java continue statement with label example shows how to use java continue statement to skip to next iteration of the labeled loop.
Here is the Java Example for the program JavaContinueWithLabelExample :
import java.util.Scanner;
public class JavaContinueWithLabelExample
{
public static void main(String[] args)
{
try
{
int n ;
System.out.println("Enter an the Starting Number");
Scanner scan = new Scanner(System.in);
n = scan.nextInt();
if ( n < 0 )
System.out.print("Please Enter Number should be non-negative.");
else
{
firstforloop: for (int i = n;i<=100; i++)
{
secondforloop: for (int j = n; j < i; j++)
{
if (i % j == 0)
{
continue firstforloop;
}
}
System.out.print(i +",");
if (i == 61)
{
continue firstforloop;
}
}
}
}
catch (Exception e){}
}
}