Javatpoint Logo
Javatpoint Logo

Java EnumMap get() method

The get() method of Java EnumMap class is used to get the mapped value of the specified key.

Syntax

Parameters

key - the key whose associated value is to be returned

Returns

This method returns the value to which the specified key is mapped.

  • This method returns null if this map contains no mapping for the key.
  • this method returns v if this map contains a mapping from a key k to a value v such that (key == k).

Exception

NA

Example 1

Test it Now

Output:

Map: {CSS=1, Python=2, PHP=3, Java=4}
Tutorial.CSS value: 1
Tutorial.Javascript value: null

Example 2

Test it Now

Output:

Map: {Monday=1, Tuesday=2, Wednesday=3}
Days.Monday value: 1
Days.Thursday value: null

Example 3

Test it Now

Output:

Map: {January=1, February=2, March=3, April=4}
Months.March value: 3
Months.May value: null
Next TopicJava EnumMap



Please Share

facebook twitter google plus pinterest