getOrDefault


Description:

public static V getOrDefault<K,V> (HashMap<K,V> map, K key, V defaultValue)

Returns the value for the key, or defaultValue when key is missing.

Parameters:

map

the source map.

key

the key to look up.

defaultValue

fallback value for missing key.

Returns:

the mapped value or fallback.