Java tagged foundation of break and continue

Label refers to the back followed by a colon identifier, such as: "lable:"

Java is for the sole use labels in place before the loop, while the Settings tab before the cycle is the only reason is: going to nest another cycle. Since the break and continue keywords will normally interrupt only the current loop, when used with a label they'll interrupt to where the label exists.

package lable;
/*
 * 打印101~150之间的质数
 */
public class test {
public static void main(String[] args) {
	outer:for (int i = 101; i <= 150; i++) {
		for (int j = 2; j < i/2; j++) {
			if(i%j==0) {
				continue outer;
			}
			
		}
		System.out.print(i+" ");
	}
}
}

Here Insert Picture DescriptionHere Insert Picture Description

Guess you like

Origin blog.csdn.net/erhuobuer/article/details/94741456