ConcurrentSkipListMap containsKey() method in Java with Examples
The containsKey() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns a true boolean value if the specified element is present in this map otherwise it returns false.
Syntax:
public boolean containsKey(Object ob)
Parameter: The function accepts a single mandatory parameter ob which specifies the key whose presence in this map is to be tested.
Return Value: The function returns true if this map contains a mapping for the specified key.
Below programs illustrate the above method:
Program 1:
// Java Program Demonstrate containsKey() // method of ConcurrentSkipListMap import java.util.concurrent.*; class GFG { public static void main(String[] args) { // Initializing the map ConcurrentSkipListMap<Integer, Integer> mpp = new ConcurrentSkipListMap<Integer, Integer>(); // Adding elements to this map for (int i = 1; i <= 5; i++) mpp.put(i, i); // Checks if 9 is present in the map if (mpp.containsKey(9)) System.out.println("9 is present" + " in the mpp."); else System.out.println("9 is not present" + " in the mpp."); } } |
Program 2:
// Java Program Demonstrate containsKey() // method of ConcurrentSkipListMap import java.util.concurrent.*; class GFG { public static void main(String[] args) { // Initializing the map ConcurrentSkipListMap<Integer, Integer> mpp = new ConcurrentSkipListMap<Integer, Integer>(); // Adding elements to this map for (int i = 1; i <= 5; i++) mpp.put(i, i); // Checks if 4 is present in the map if (mpp.containsKey(4)) System.out.println("4 is present" + " in the mpp."); else System.out.println("4 is not present" + " in the mpp."); } } |
Recommended Posts:
- ConcurrentSkipListMap put() method in Java with Examples
- ConcurrentSkipListMap isEmpty() method in Java with Examples
- ConcurrentSkipListMap size() method in Java with Examples
- ConcurrentSkipListMap remove() method in Java with Examples
- ConcurrentSkipListMap clone() method in Java with Examples
- ConcurrentSkipListMap clear() method in Java with Examples
- ConcurrentSkipListMap ceilingKey() method in Java with Examples
- ConcurrentSkipListMap containsValue() method in Java with Examples
- ConcurrentSkipListMap equals() method in Java with Examples
- Map containsKey() method in Java with Examples
- Properties containsKey(value) method in Java with Examples
- AbstractMap containsKey() Method in Java with Examples
- Hashmap methods in Java with Examples | Set 2 (keySet(), values(), containsKey()..)
- HashMap containsKey() Method in Java
- ConcurrentHashMap containsKey() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


