Java EnumMap keySet() methodThe 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). SyntaxParametersNA ReturnsThis method returns a set view of the keys contained in the enum map. ExceptionNA Example 1Test it NowOutput: Map: {CSS=1, Python=2, PHP=3, Java=4} KeySet: [CSS, Python, PHP, Java] Example 2Test it NowOutput: Map: {Monday=1, Tuesday=2, Wednesday=3} KeySet: [Monday, Tuesday, Wednesday] Example 3Test it NowOutput: Map: {January=1, February=2, March=3, April=4} KeySet: [January, February, March, April]
Next TopicJava EnumMap
|