You can't take int
as argument in Map.Entry#getValue()
. So in your code it should be entry.getValue()
instead of entry.getValue(i)
. Now apart from this your singleValues
is an ArrayList
. so you can't subtract it from integer average
in line (entry.getValue(i).singleValues) - average)
. You have to first extract out the element from the ArrayList
and then subtract it from the average
. Your for loop should be something like this:
for (int i = 0; i < entry.getValue().occurrences ; i ++)// i < entry.getValue() to avoid IndexOutOfBoundsException
{
temp += ((entry.getValue().singleValues.get(i)) - average)*((entry.getValue().singleValues.get(i)) - average);
variance = temp/entry.getValue().occurrences;
}