Java - How to deep copy HashSet, HashMap

Deep copy HashSet

HashSet set = new HashSet();
HashSet set2 = new HashSet();
set2.addAll(set);

or

HashSet set = new HashSet();
HashSet set2 = new HashSet(set);

Deep copy HashMap

HashMap map = new HashMap<>();
HashMap map2 = new HashMap<>();
map2.putAll(map);

or

HashMap map = new HashMap<>();
HashMap map2 = new HashMap<>(map);

Anyway, Good luck, Richardo! -- 09/27/2016

你可能感兴趣的:(Java - How to deep copy HashSet, HashMap)