Wednesday, 7 February 2018

Program to understand Continuebreak Label

class Continuebreak
  {
  public static void main(String args[])
  {
  LOOP1:for(int i=1;i<100;i++)
  {
  System.out.println(" ");
  if(i>=10) break;
  LOOP2:for(int j=1;j<100;j++)
  {
  System.out.print(" * ");
  if(j==i)
  continue LOOP1;
  }
  }
  System.out.println("terminated by break LOOP1");
  }
  }

Output:
 
   *
   *  *
   *  *  *
   *  *  *  *
   *  *  *  *  *
   *  *  *  *  *  *
   *  *  *  *  *  *  *
   *  *  *  *  *  *  *  *
   *  *  *  *  *  *  *  *  *
  terminated by break LOOP1

No comments:

Post a Comment