WeakHashMap.putAll(Map <? extends K ,? extends V > m) has the following syntax.
public void putAll(Map <? extends K ,? extends V > m)
In the following code shows how to use WeakHashMap.putAll(Map <? extends K ,? extends V > m) method.
//from w ww. j a va 2 s .c o m import java.util.Map; import java.util.WeakHashMap; public class Main { public static void main(String[] args) { Map<String, String> weakHashMapOne = new WeakHashMap<String, String> (); Map<String, String> weakHashMapTwo = new WeakHashMap<String, String> (); System.out.println("Populating two Maps"); weakHashMapOne.put("1", "first"); weakHashMapOne.put("2", "two"); weakHashMapOne.put("3", "from java2s.com"); weakHashMapTwo.put("1", "1st"); weakHashMapTwo.put("2", "2nd"); weakHashMapTwo.put("3", "3rd"); // checking Map System.out.println("Before - Map 1: "+weakHashMapOne); System.out.println("Before - Map 2: "+weakHashMapTwo); // putting map 2 into map1 weakHashMapOne.putAll(weakHashMapTwo); System.out.println("After - Map 1: "+weakHashMapOne); System.out.println("After - Map 2: "+weakHashMapTwo); } }
The code above generates the following result.