Stream迭代hashMap并处理数据

问题描述 投票:0回答:2

我想使用java Stream迭代hashmap,并希望为每个键执行一个内联函数然后求和]

Map<Integer, Integer>  myMap= new HashMap<Integer, Integer>() {{ 
                put(5000, 0);
                put(1000, 10);
            }};

myMap.entrySet().stream().map(e-> {/* want to fetch the corresponding value and increment by X  and find the sum*/ });
java java-8 java-stream
2个回答
3
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.