I work on a Java application.
There is a Getter that corresponds to a integer field (score).
My goal is to calculate the average on that field. I decided to make an array, then to caculate the count and the sum of that array.
But I'm really getting stuck in both that Java syntax and "state of mind"..
Here is my snippet :
public void setPersonData2(List<Person> persons2) {
// Try to make a count of the array
int[] scoreCounter = new int[100]; // 100 is by default since we don't know the number of values
for (Person p : persons2) {
int score = p.getScoreTheo(); // Getter
Arrays.fill(scoreCounter, score);
// Try to delete all values equal to zero
int[] scoreCounter2 = IntStream.of(scoreCounter).filter(i -> i != 0).toArray();
// Calculate count
int test = scoreCounter2.length;
System.out.println(test);
}
}
Could you help me ?