Skip to content

Commit 6c74289

Browse files
Add files via upload
1 parent fe6c463 commit 6c74289

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

MapOf.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.Map;
2+
public class MapOf {
3+
public static void main(String[] args) throws Exception {
4+
// Map.of(K,V)
5+
Map<String, Integer> map = Map.of("a", 1, "b", 2, "c", 3);
6+
System.out.println("Map:" + map);
7+
8+
9+
10+
}
11+
12+
13+
}

MapOfEntries.java

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import java.util.Map;
2+
public class MapOfEntries {
3+
//Map.OfEntries
4+
public static void main(String[] args) throws Exception {
5+
Map<String, Integer> map = Map.ofEntries(Map.entry("a", 1), Map.entry("b", 2), Map.entry("c", 3));
6+
System.out.println("Map:" + map);
7+
}
8+
9+
}

0 commit comments

Comments
 (0)