Java EnumMap containsKey() method
Last Updated : 17 Mar 2025
The containsKey() method of Java EnumMap class is used to check whether a specified key is present in this map or not. This method returns true if this map contains a mapping for the specified key.
Syntax
Parameters
key - the key whose presence in this map is to be tested
Returns
This method returns true if this map contains a mapping for the specified key.
Exception
NA
Example 1
Output:
{Java=1, Python=2, PHP=3, Android=4, AngularJS=5}
Tutorial.Java has a mapping: true
Tutorial.PHP has a mapping: true
Example 2
Output:
{Monday=1, Tuesday=2, Wednesday=3, Thursday=4}
Days.Tuesday has a mapping: true
Days.Thursday has a mapping: true