I'm having an assignment where I need to count the prime numbers in an array list. There are several solutions to this here on Stackoverflow but I need to do it in another way. I have the initializing of the array list int the method head itself, not the body. I believe there is a difference but I might be wrong.
I need to use this method:
public static int countPrimeNumbers(ArrayList<Integer> list) {
}
So far I'm coming up with this code:
public static int countPrimeNumbers(ArrayList<Integer> list) {
list = new ArrayList<Integer>();
int n = 0;
int count = 0;
System.out.println(list);
for(int i=2; i<list.size(); i++) {
if(n%i==0)
count++;
}
return count;
}
But I'm not sure if it's somwehere near completion since I don't know how to call it from Main. Regards