import java.util.HashMap;
import java.util.Map;
public class MainClass {
public static void main(String[] a) {
Map map = new HashMap();
map.put("key1", "value1");
map.put("key2", "value2");
map.put("key3", "value3");
map.put(null, null);
Map map2 = new HashMap();
map2.put("key4", "value4");
map2.put("key5", "value5");
map2.put("key6", "value6");
map.putAll(map2);
System.out.println(map);
}
}
{key1=value1, key3=value3, key6=value6, null=null, key5=value5, key2=value2, key4=value4}
The value is replaced for every key in the passed-in map that already exists in the HashMap.