WeakHashMap values Example


WeakHashMap class values example.ublic Collection values() Returns a Collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.

Here is the code

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

public class Values {
     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("values of the map " + map.values());
    }
}

Output
map = {4=D, 3=C, 2=B, 1=A}
values of the map [D, C, B, A]

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US