Here you can find the source of copyMap(HashMap map)
public static HashMap copyMap(HashMap map)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; public class Main { public static HashMap copyMap(HashMap map) { HashMap<Object, Object> newmap = new HashMap<>(10); for (Object key : map.keySet()) { newmap.put(key, map.get(key)); }/*from ww w . jav a 2 s . c o m*/ return newmap; } }