Notes
In Apex, the containsKey(key)
method is used with a Map
to check whether a specific key exists in the map. This method returns a Boolean value indicating whether the specified key is present in the map.
Here's an example:
Map<String, Integer> myMap = new Map<String, Integer>{
'apple' => 5,
'banana' => 3,
'cherry' => 8
};
Boolean containsKey = myMap.containsKey('banana');
System.debug('Does the map contain the key? ' + containsKey);
Output: Does the map contain the key? true
Video
Video does not exists.