Mega Code Archive
Copying all the key-value pairs from one Hashtable (or any Map) into another Hashtable
If any keys already exist in the hash table, their value will be replaced
if they are also found in the passed-in map.
public void putAll(Map map)
import java.util.Hashtable;
public class MainClass {
public static void main(String[] s) {
Hashtable table = new Hashtable();
table.put("key1", "value1");
table.put("key2", "value2");
table.put("key3", "value3");
Hashtable table2 = new Hashtable();
table2.put("key4", "value4");
table2.put("key5", "value5");
table2.put("key6", "value6");
table2.putAll(table);
System.out.println(table2);
}
}
{key6=value6, key5=value5, key4=value4, key3=value3, key2=value2, key1=value1}