试试下面的代码:
public class Test {
public static void main(String[] args){
int[] sushuArray = new int[]{3,6,4,13,7,5,4};
int count = 0;
for(int i : sushuArray){
if(sushu(i)){
count++;
}
}
System.out.println("素数个数为:"+count+"个");
}
private static boolean sushu(int a){
for(int i=2; i<a; i++){
if(a%i == 0){
return false;
}
}
return true;
}
}