putAll(Map<?, ?> m) adds another map
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);
}
}
Home
Java Book
Collection
Java Book
Collection
HashMap:
- HashMap Class
- new HashMap<K, V>()
- clear() removes all elements in a HashMap
- clone() creates a copy of the HashMap
- containsKey(Object key) checks to see if the HashMap has that key
- containsValue(Object value) checks if the HashMap has that value
- entrySet() returns the key-value pair as a set
- keySet() returns the key set
- get(E o) returns the value by the key
- put(E o, E o1) add value and key to a HashMap
- putAll(Map<?, ?> m) adds another map
- remove(Object key) deletes an entry by a key
- size() returns the size of a HashMap
- values() returns the value of the