public static void main(String[] args) {
Map<Long, Double> map = new HashMap<>();
map.put(2L, 1.1d);
map.put(3L, 2d);
map.put(5L, 3d);
//将value值相加
Double reduceValue = map.values().stream().reduce(0d, Double::sum, Double::sum);
//将key值相加
Long reduceKey = map.keySet().stream().reduce(0L, Long::sum, Long::sum);
System.out.println(reduceValue);
System.out.println(reduceKey);
}
12-07
3001

04-19
3266

06-07
2086
