Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Map; public class Main { public static <K, V> V getOrElse(Map<K, V> m, K k, V def) { V v = m.get(k); if (v != null) return v; else return def; } }