IdentityHashMap putAll Example
IdentityHashMap class putAll example. This example shows you how to use putAll method.
IdentityHashMap class putAll example. public void putAll(Map) Copies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map 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 IdentityHashMap class in java.util package
* version 26 May 2008
* author Rose India
*/
import java.util.*;
public class PutAll {
public static void main(String args[]) {
IdentityHashMap map = new IdentityHashMap();
IdentityHashMap map1 = new IdentityHashMap();
//Add the mapping into the map
map.put(1, "A");
map.put(2, "A");
map.put(3, "B");
map1.putAll(map);
System.out.println("map = " + map);
System.out.println("map1 = " + map1);
}
} |
Output
map = {2=A, 1=A, 3=B}
map1 = {2=A, 1=A, 3=B} |
|