WeakHashMap put Example

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


WeakHashMap class put example.public V put(K key, V value) Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.

Here is the code

/**
 * @ # Put.java
 * A class repersenting use to put method 
 * of WeakHashMap class in java.util package
 * version 22 May 2008
 * author Rose India 
 */
import java.util.*;

public class Put {
    public static void main(String args[]){
        WeakHashMap map= new WeakHashMap();
        map.put(1,"A");
        map.put(2,"B");
        map.put(3,"C");
        map.put(4,"D");
        
        System.out.println("map = " + map);
    }
}

Output
 map = {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