java.util.IdentityHashMap.containsKey() Method
Advertisements
Description
The containsKey(Object key) method is used to test whether the specified object reference is a key in this identity hash map.
Declaration
Following is the declaration for java.util.IdentityHashMap.containsKey() method.
public boolean containsKey(Object key)
Parameters
key--This is the possible key to be checked.
Return Value
The method call returns 'true' if the specified object reference is a key in this map.
Exception
NA
Example
The following example shows the usage of java.util.IdentityHashMap.containsKey()
package com.tutorialspoint;
import java.util.*;
public class IdentityHashMapDemo {
public static void main(String args[]) {
// create identity hash map
IdentityHashMap ihmap = new IdentityHashMap();
// populate the map
ihmap.put(1, "java");
ihmap.put(2, "util");
ihmap.put(3, "package");
// check if key 3 exists
boolean isavailable=ihmap.containsKey(3);
System.out.println("Is key '3' exists: " + isavailable);
}
}
Let us compile and run the above program, this will produce the following result.
Is key '3' exists: true