I have following two methods:
public static double calculateMeanInt(List<Integer> numbers) {
double sum = 0.0;
for(Integer number : numbers)
sum += number;
return sum/numbers.size();
}
public static double calculateMeanDouble(List<Double> numbers) {
double sum = 0.0;
for(Double number : numbers)
sum += number;
return sum/numbers.size();
}
Do you have an elegant solution (other than using type casting and Object) that will avoid the duplicate code above and will use a single method name?