Using a Labeled Continue Statement : continue « Statements « SCJP






public class MainClass{
 public static void main(String[] args) {
  outerloop: for(int i=0; i<10; ++i) {
   innerloop: for(int j=0; j<10; ++j) {
    if((i+j) % 5 == 0) continue outerloop;
    if((i+j) % 5 == 3) continue innerloop;
    System.out.println("i = "+i+", j = "+j);
   }
  }
 }
}
i = 1, j = 0
i = 1, j = 1
i = 1, j = 3
i = 2, j = 0
i = 2, j = 2
i = 3, j = 1
i = 4, j = 0
i = 6, j = 0
i = 6, j = 1
i = 6, j = 3
i = 7, j = 0
i = 7, j = 2
i = 8, j = 1
i = 9, j = 0








5.6.continue
5.6.1.Both the break statement and the continue statement can be unlabeled or labeled.
5.6.2.continue with label
5.6.3.The continue statement terminates the current pass through a loop.
5.6.4.continue is able to skip out of multiple levels of loop.
5.6.5.Using a Labeled Continue Statement