WeakHashMap putAll Example

WeakHashMap class putAll example. This example shows you how to use putAll method.


WeakHashMap 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 WeakHashMap class in java.util package
 * version 22 May 2008
 * author Rose India 
 */
import java.util.*;

public class PutAll {

    public static void main(String args[]) {
        WeakHashMap map = new WeakHashMap();
        WeakHashMap map1 = new WeakHashMap();
        map.put(1"A");
        map.put(2"B");
        map.put(3"C");
        map.put(4"D");

        map1.putAll(map);
        System.out.println("map1 = " + map);
    }
}

Output
 map1 = {4=D, 3=C, 2=B, 1=A}

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US