IdentityHashMap containsValue Example
IdentityHashMap class containsValue example. This example shows you how to use containsValue method.
IdentityHashMap class containsValue example.public boolean containsValue(Object ) Tests whether the specified object reference is a value in this identity hash map.
Here is the code
/**
* @ # ContainsValue.java
* A class repersenting use to containsValue method
* of IdentityHashMap class in java.util package
* version 26 May 2008
* author Rose India
*/
import java.util.*;
public class ContainsValue {
public static void main(String args[]) {
IdentityHashMap map = new IdentityHashMap();
//Add the mapping into the map
map.put(1, "A");
map.put(2, "A");
map.put(3, "B");
System.out.println("Map " + map);
//Tests whether the specified object reference
//is a value in this identity hash map.
System.out.println(map.containsValue("A"));
}
} |
|