我想写一个java程序,它确定如果一个数组的所有元素是质数。这里是我的代码:确定是否所有元素的数组是素数
boolean allPrimes(int[] ade){
int i = 0; //counter
boolean Prime = true; //initial boolean value
while (i<ade.length && !Prime){
if (p.isPrime(ade[i])) //function which determines if an int is prime.
Prime = true;
else
Prime = false;
i=i+1;
}
return Prime;
}
我不认为这是正确的,因为我做了一些测试,他们失败了。我究竟做错了什么?感谢
wouldnt it'while(i
它是http://stackoverflow.com/questions/8114442/error-with-repetition-which-i-cant-spot – jjcastil