goto(不是很重要)

 1 package com.pingfan.struct;
 2 
 3 public class GotoDemo {
 4     public static void main(String[] args) {
 5         //打印101-160之间的所有质数
 6         //质数是指在大于1的自然数中,除了1和它本身以外不再有其他因数的自然数。
 7 
 8         int count = 0;
 9         //不建议使用
10         outer:for (int i = 101; i < 150; i++) {
11             for (int j = 2; j < i/2; j++) {
12                 if (i % j == 0){
13                     continue outer;
14                 }
15             }
16             System.out.print(i + " ");
17         }
18     }
19 }

 

posted @ 2021-03-23 16:00  HeartlessHero  阅读(71)  评论(0)    收藏  举报