I have a list that has to accept either a list of Integer/Double/Float/Long and return the sum. I tried this
public static Number getSum(List< ? extends Number> lst) {
return lst.stream().reduce(0.0, (a, b) -> a+b);
}
But I am getting this error in compile time
The operator + is undefined for the argument type(s) capture#3-of ? extends java.lang.Number, capture#3-of ? extends java.lang.Number