Java WeakHashMap.get(Object key)
Syntax
WeakHashMap.get(Object key) has the following syntax.
public V get(Object key)
Example
In the following code shows how to use WeakHashMap.get(Object key) method.
import java.util.Map;
import java.util.WeakHashMap;
// w w w . j a va 2 s . co m
public class Main {
public static void main(String[] args) {
Map<String, String> weakHashMap = new WeakHashMap<String, String> ();
weakHashMap.put("1", "first");
weakHashMap.put("2", "two");
weakHashMap.put("3", "from java2s.com");
// check existence of value for key 2
System.out.println("Checking value for key 2");
System.out.println(weakHashMap.get("2"));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »