Java Blog

 
 
 
 public class JAVA_034
 {

    public static void main(String[] args)
    {
       int nValues=50;

       System.out.println(\"The Prime Numbers from 1 to 50 are : \");

       OuterLoop:

       for(int i=1;i<=nValues;i++)
       {
          for(int j=2;j<i;j++)
          {
             if((i%j)==0)
                break OuterLoop;
          }

          System.out.println(i);
       }

       System.out.println(\"The rest of the Loop iterations were skipped as 4 is not a Prime Number\");
    }
 }

 
 
Didn't find what you were looking for? Find more on Program to show the use of Labeled Break Statement