Skip to Content

Java continue statement with label example

  1. /*
  2.   Java continue statement with label example.
  3.   This example shows how to use java continue statement to skip to next iteration
  4.   of the labeled loop.
  5.    
  6. */
  7.  
  8. public class JavaContinueWithLabelExample {
  9.  
  10.   public static void main(String[] args) {
  11.    
  12.     int intArray[][] = new int[][]{{1,2},{2,3}};
  13.    
  14.     Outer:
  15.     for(int i=0; i < intArray.length; i++)
  16.     {
  17.       for(int j=0; j < intArray[i].length ; j++)
  18.       {
  19.         if(intArray[i][j] == 3)
  20.           continue Outer;
  21.         System.out.println("Element is : " + intArray[i][j]);
  22.       }
  23.     }
  24.      
  25.   }
  26. }
  27.  
  28. /*
  29. Element is : 1
  30. Element is : 2
  31. Element is : 2
  32. */