Map: putAll(Map m) : Map « java.util « Java by API






Map: putAll(Map m)

 

import java.util.HashMap;
import java.util.Map;

public class Main {
  public static void main(String[] a) {
    Map<String,String> map = new HashMap<String,String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
    map.put(null, null);

    Map<String,String> map2 = new HashMap<String,String>();
    map2.put("key4", "value4");
    map2.put("key5", "value5");
    map2.put("key6", "value6");
    map.putAll(map2);

    System.out.println(map);
  }
}

   
  








Related examples in the same category

1.implements Map
2.java.util.Map.Entry
3.Map: clear()
4.Map: containsKey(Object key)
5.Map: containsValue(Object value)
6.Map: equals(Object o)
7.Map: get(Object key)
8.Map.Entry: getKey()
9.Map.Entry: getValue()
10.Map: keySet()
11.Map: put(T key, T value)
12.Map: remove(Object key)
13.Map: size()
14.Map: values()