java.util.IdentityHashMap.putAll() 方法


java.util.IdentityHashMap.putAll() 方法

package com.codingdict;

import java.util.*;

public class IdentityHashMapDemo {
   public static void main(String args[]) {

      // create 2 identity hash maps
      IdentityHashMap ihmap1 = new IdentityHashMap();
      IdentityHashMap ihmap2 = new IdentityHashMap();

      // populate the ihmap1
      ihmap1.put(1, "java");
      ihmap1.put(2, "util");
      ihmap1.put(3, "package");

      System.out.println("Value of ihmap1 before: " + ihmap1);
      System.out.println("Value of ihmap2 before: " + ihmap2);

      // put all values from ihmap1 to ihmap2
      ihmap2.putAll(ihmap1);

      System.out.println("Value of ihmap2 after: " + ihmap2);
   }    
}