Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class Main { /** * @param map map * @return map deep copy */ public static Map<String, Set<String>> cloneMap(Map<String, Set<String>> map) { final Map<String, Set<String>> clone = new HashMap<>(map.size()); for (Map.Entry<String, Set<String>> entry : map.entrySet()) { final Set<String> cloneSet = new HashSet<>(entry.getValue()); clone.put(entry.getKey(), cloneSet); } return clone; } }