Android examples for java.util:Map
safe Get from Map
//package com.book2s; import java.util.Map; public class Main { public static <K, V> V safeGet(Map<K, V> map, K key, V defaultValue) { if (map == null) { return null; } else {/*from w w w . j a v a2 s .c o m*/ return map.containsKey(key) ? map.get(key) : defaultValue; } } public static <K, V> V safeGet(Map<K, V> map, K key) { if (map == null) { return null; } else { return map.containsKey(key) ? map.get(key) : null; } } }