Java examples for java.util:Map Value
get value by key from a may Or return Default
//package com.java2s; import java.util.Map; public class Main { @SuppressWarnings("unchecked") public static <K, V> V getOrDefault(Map<K, ?> map, K key, V defaultValue) { final Object v = map.get(key); if (v == null) return defaultValue; else/*from w ww . ja v a 2 s . c om*/ return (V) v; } }