The article directories

  • Jump control statement -continue
    • 1. Basic Introduction
    • 2. Basic Grammar:
    • 3. Take while with continue as an example, schematic diagram
    • 4. Quick Start cases
    • 5. Detailed case analysis and explanation:

Jump control statement -continue

1. Basic Introduction

  1. The continue statement terminates the loop and continues the next loop.
  2. When a continue statement appears in the body of a multi-layer nested loop, you can use the label to indicate which layer of the loop to skip, just as you did with the previous label.

2. Basic Grammar:

{...continue; ... }Copy the code

3. Take while with continue as an example, schematic diagram

4. Quick Start cases

Continue01.java

  • wheni == 2“, the loop is broken out and the next loop is executed. If it is not equal to 2, the following code will still execute.
	int i = 1;
	while (i <= 4){
	    i++;
	    if (i == 2) {continue;
	    }
	    System.out.println("i="+i);
	}
Copy the code

5. Detailed case analysis and explanation:

ContinueDetail.java

	abel1:
	for(int j = 0; j < 2; j++){
	    label2:
	    for(int i = 0; i < 10; i++){
	        if(i == 2) {// See what values are output, and parse
	            //continue ; // Equivalent to continue label2
	            //continue label2; / / equivalent continue;
	            continue label1; // output 2 times [0,1]
	        }
	        System.out.println("i = " + i);// output twice [0,1,3,4,5,6,7,8,9]}}Copy the code