Skip to content

Commit 39962ad

Browse files
Add files via upload
1 parent 8d5d832 commit 39962ad

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

ConcurrentHashMapMethods18.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.concurrent.ConcurrentHashMap;
2+
public class ConcurrentHashMapMethods18 {
3+
public static void main(String[] args) throws Exception {
4+
//reduceEntriesToInt​(long parallelismThreshold, ToIntFunction<Map.Entry<K,​V>> transformer, int basis, IntBinaryOperator reducer)
5+
6+
ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
7+
map.put("one", "1");
8+
map.put("two", "2");
9+
map.put("three", "3");
10+
map.put("four", "4");
11+
System.out.println("Map:" + map);
12+
13+
int result = map.reduceEntriesToInt(2, (entry) -> {
14+
return Integer.parseInt(entry.getValue());
15+
}, 0, (a, b) -> {
16+
return a + b;
17+
});
18+
19+
System.out.println("Result:" + result);
20+
21+
22+
}
23+
}
24+
25+

0 commit comments

Comments
 (0)