Javatpoint Logo
Javatpoint Logo

Java EnumMap size() method

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

Test it Now

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

Test it Now

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
Next TopicJava EnumMap



Help Others, Please Share

facebook twitter pinterest