I want the equivalent of this with a stream:
public static <T extends Number> T getSum(final Map<String, T> data) {
T sum = 0;
for (String key: data.keySet())
sum += data.get(key);
return sum;
}
This code doesn't actually compile because 0 cannot be assigned to type T, but you get the idea.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…