Javatpoint Logo
Javatpoint Logo

Java EnumMap keySet() method

The keySet() method of Java EnumMap class is used to get the set view of the keys contained in the map. This method returns a set of the keys in the natural order (the order in which the enum constants are declared).

Syntax

Parameters

NA

Returns

This method returns a set view of the keys contained in the enum map.

Exception

NA

Example 1

Test it Now

Output:

Map: {CSS=1, Python=2, PHP=3, Java=4}
KeySet: [CSS, Python, PHP, Java]

Example 2

Test it Now

Output:

Map: {Monday=1, Tuesday=2, Wednesday=3}
KeySet: [Monday, Tuesday, Wednesday]

Example 3

Test it Now

Output:

Map: {January=1, February=2, March=3, April=4}
KeySet: [January, February, March, April]
Next TopicJava EnumMap



Please Share

facebook twitter google plus pinterest