ConcurrentHashMap containsKey() Method in Java
The java.util.concurrent.ConcurrentHashMap.containsKey() method is an in-built function in Java which accepts a parameter and checks whether it is a key in this map.
Parameters: The method accepts a single parameter key_element of object type which is to be checked for whether it is a key or not.
Return Value: The method returns true if the specified key_element is a key of this map and false otherwise.
Exception: The function throws NullPointerException when the specified key_element is null.
Below programs illustrate the use of java.util.concurrent.ConcurrentHashMap.containsKey() method :
Program 1: This program involves mapping String Values to Integer Keys.
105 is not a key. 100 is a key.
Program 2: This program involves mapping Integer Values to String Keys.
GFG is a key. Geek is not a key.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.