Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { /** * Assign or make new map from source map. Use HashMap for new map. * * @param src * source map * @param dst * destination map * @return dst or new map if dst null */ public static <K, V> Map<K, V> instanceMap(Map<K, V> src, Map<K, V> dst) { Map<K, V> ret = null; if (src != null) { if (dst == null) { dst = new HashMap<>(); } dst.clear(); dst.putAll(src); ret = dst; } return ret; } }