Skip to content

Commit e14cce1

Browse files
Add files via upload
1 parent 3e659c5 commit e14cce1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ConcurrentHashMapMethods2.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.concurrent.ConcurrentHashMap;
2+
public class ConcurrentHashMapMethods2 {
3+
public static void main(String[] args) throws Exception {
4+
ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
5+
6+
map.put("1", "one");
7+
map.put("2", "two");
8+
map.put("3", "three");
9+
map.put("4", "four");
10+
map.put("5", "five");
11+
map.put("6", "six");
12+
map.put("7", "seven");
13+
map.put("8", "eight");
14+
15+
System.out.println("Map:" + map);
16+
17+
//forEach​(long parallelismThreshold, BiFunction<? super K,​? super V,​? extends U> transformer, Consumer<? super U> action)
18+
19+
map.forEach(1, (k, v) -> {
20+
System.out.println("Key: " + k + " Value: " + v);
21+
return v;
22+
}, v -> System.out.println("Value: " + v));
23+
24+
System.out.println(" ");
25+
26+
}
27+
28+
}

0 commit comments

Comments
 (0)