Java

使用控制嵌套循环跳转,打印输出10 ~ 150之间的质数

代码:

public class Testcotinue {
    public static void main(String[] args) {
        //打印101~150之间所有的质数
        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 + "  ");
        }
    }
}

输出结果:

原文地址:https://www.cnblogs.com/kl-1998/p/10562997.html