WeakHashMap entrySet Example

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


WeakHashMap class entrySet example.public Set entrySet() Returns a Set view of the mappings 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
/**
 * @ # EntrySet.java
 * A class repersenting use to entrySet method 
 * of WeakHashMap class in java.util package
 * version 19 May 2008
 * author Rose India 
 */
import java.util.*;
public class EntrySet {
    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);
        
        //Returns a Set view of the mappings contained in this map.
        Set set=map.entrySet();
        System.out.println("set = " + set);
    }
}

Output
map = {4=D, 3=C, 2=B, 1=A}
set = [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