Java EnumMap size() method
Last Updated : 17 Mar 2025
The size() method of Java EnumMap class is used to get the size of the EnumMap. This method returns an integer whose value is the number of key-value mappings in this EnumMap.
Syntax
Parameters
NA
Returns
This method returns the size of this EnumMap.
Exception
NA
Example 1
Output:
Map: {Java=1, CSS=2, Python=3, Android=4}
Number of mappings: 4
Map: {Java=1, CSS=2, Python=3, Android=4, Javascript=5}
Number of mappings: 5
Example 2
Output:
Map: {Monday=1, Tuesday=2, Wednesday=3}
Number of mappings: 3
Map: {Monday=1, Tuesday=2, Wednesday=3, Thursday=4}
Number of mappings: 4