containsValue(Object): This method is available in java.util.IdentityHashMap class of Java.
Syntax:
boolean java.util.IdentityHashMap.containsValue(Object value)
This method takes one argument. This method tests whether the specified object reference is a value in this identity hashmap.
Parameters: One parameter is required for this method.
value: value whose presence in this map is to be tested.
Returns: true if this map maps one or more keys to the specified object reference.
Exceptions: NA
Approach
Java
import java.util.IdentityHashMap;public class IdentityHashMapcontainsValue {public static void main(String args[]) {IdentityHashMap<String, Integer> identityHashMap =new IdentityHashMap<String, Integer>();identityHashMap.put("Java", 1);identityHashMap.put("Hello", 2);Object value = 1;System.out.println(identityHashMap.containsValue(value));}}
Output:
true
No comments:
Post a Comment