Java Hashtable.putAll(Map <? extends K ,? extends V > t)
Syntax
Hashtable.putAll(Map <? extends K ,? extends V > t) has the following syntax.
public void putAll(Map <? extends K ,? extends V> t)
Example
In the following code shows how to use Hashtable.putAll(Map <? extends K ,? extends V > t) method.
/*from w w w . j ava 2 s .c om*/
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
public class Main {
public static void main(String args[]) {
// create hash table
Hashtable htable1 = new Hashtable();
// create Map
Map<String,String> map=new HashMap<String,String>();
// put values in map
map.put("1","tutorial");
map.put("2","from");
map.put("3","java2s.com");
System.out.println("Initial hash table value: "+htable1);
System.out.println("Map values: "+map);
// put map values in table
htable1.putAll(map);
System.out.println("Hash table value after put all: "+htable1);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »