运行错误
程序代码:
package boy; public class Test { public static void main(String[] args) { SuShu(1, 1000); } public static void SuShu(int a, int b) {//a到b之间的素数个数 int count = 0; for (int i = a; i <= b; i++) { if (isPrime(i)) { count++; System.out.println(i + " "); if (count % 10 == 0) { System.out.println(); } } } System.out.println(); System.out.println("在" + a + "和" + b + "之间有" + count + "个素数"); } public static boolean isPrime(int a) {//判断素数 boolean flag = true; if (a == 1) flag = false; else { for (int i = 2; i <= Math.sqrt(a); i++) { if (a % i == 0) { flag = false; break; } else if (a == 1) { flag = false; break; } else { flag = true; } } } return flag; } }
错误: 找不到或无法加载主类 boy.Test
原因: java.lang.ClassNotFoundException: boy.Test