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 }

浙公网安备 33010602011771号