1Map<String, String> myMap = new HashMap<String, String>() {{
2 put("a", "b");
3 put("c", "d");
4 }};
1Map<String, String> emptyMap = Map.of();
2Map<String, String> singletonMap = Map.of("key1", "value");
3Map<String, String> map = Map.of("key1","value1", "key2", "value2");
4
1//remember to first import java.util.*; first
2
3//you can swap out string or integer for other data types
4Map<String, Integer> d = new HashMap<>();
5
1 HashMap<Integer,String> map=new HashMap<Integer,String>();//Creating HashMap
2
1HashMap<Integer,String> map=new HashMap<Integer,String>();//key is integer, value is String