Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » Homework HelpRSS Feeds

Program to show the use of Labeled Break Statement

Posted By: Carol Garcia     Category: Java     Views: 2480

A Java Program to show the use of Labeled Break Statement.

Code for Program to show the use of Labeled Break Statement in Java

publicclass JAVA_034
 {

    publicstaticvoid 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");
    }
 }
  
Share: 


Didn't find what you were looking for? Find more on Program to show the use of Labeled Break Statement Or get search suggestion and latest updates.

Carol Garcia
Carol Garcia author of Program to show the use of Labeled Break Statement is from Baltimore, United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!