WeakHashMap keySet Example
WeakHashMap class keySet example. This example shows you how to use keySet method.
WeakHashMap class keySet example.public Set keySet() Returns a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
Here is the code
/**
* @ # KeySet.java
* A class repersenting use to keySet method
* of WeakHashMap class in java.util package
* version 22 May 2008
* author Rose India
*/
import java.util.*;
public class KeySet {
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");
Set set=map.keySet();
System.out.println("Set = "+set);
}
} |
|