//Prime Number Calculator
import java.util.Scanner;
class PrimeNumbers {
public static void main(String[] args){
int End;
int Begin;
Scanner in = new Scanner(System.in);
//insert max value for the calculator.
System.out.println("Where should I stop?");
End = in.nextInt();
for (Begin=3; Begin<=End; Begin++){
System.out.println(Begin);
int Prime;
int PrimeList[] ;
//something is wrong around here... I don't understand what...
for (Prime:PrimeList);
PrimeList[0]=2;
if(Begin%PrimeList[Prime]!=0){
break;
}
}
}
}
我知道那里有很多素数计算器,但在学校我想做一个但我不知道我哪里出错了。
错误信息:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "Prime", Identifier expected after this token
Prime cannot be resolved to a type
Type mismatch: cannot convert from element type int to Prime
at PrimeNumbers.main(PrimeNumbers.java:25)