WeakHashMap get Example
WeakHashMap class get example. This example shows you how to use get method.
WeakHashMap class get example. public V get(Object key) Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
Here is the code
/**
* @ # Get.java
* A class repersenting use to get method
* of WeakHashMap class in java.util package
* version 19 May 2008
* author Rose India
*/
import java.util.*;
public class Get {
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);
System.out.println( map.get(1));
}
} |
Output
map = {4=D, 3=C, 2=B, 1=A}
A |
|