Hashtable putAll Example
Hashtable class putAll method example.public void putAll(Map) Copies all of the mappings from the specified map to this hashtable. These mappings will replace any mappings that this hashtable had for any of the keys currently in the specified map.
Here is the code
/**
* @ # PutAll.java
* A class repersenting use to putAll method
* of HashMap class in java.util package
* version 19 May 2008
* author Rose India
*/
import java.util.*;
public class PutAll {
public static void main(String args[]) {
Hashtable table = new Hashtable();
//Put value into the table
table.put(1, "A");
table.put(2, "B");
table.put(3, "C");
table.put(4, "D");
System.out.println("table :" + table);
Hashtable table1 = new Hashtable();
table1.putAll(table);
System.out.println("table1 :" + table);
}
} |
Output
table :{4=D, 3=C, 2=B, 1=A}
table1 :{4=D, 3=C, 2=B, 1=A} |
|