I am trying to write a method that takes in a list of numeric values - eg List<Integer>, List<Float>, List<Double> etc - and give me the average.
public double getAverage(List<? extends Number> stats) {
double sum = 0.00;
if(!stats.isEmpty()) {
// sum = stats.stream()
// .reduce(0, (a, b) -> a + b);
// return sum / stats.size();
}
}
These are the errors I get:
Operator '+' cannot be applied to 'capture<? extends java.lang.Number>', 'capture<? extends java.lang.Number>'