How to deep copy hashmap? I wanna make a copy of hashmap. When I change the keys and values in the copy, the original hashmap doesn't change. I cannot find a solution to solve this problem in the Internet. The function of putall() doesn't work.
HashMap<OWLClass, Set<OWLClass>> map1 ;
HashMap<OWLClass, Set<OWLClass>> map2 = new HashMap<OWLClass, Set<OWLClass>>();
I tried
for(OWLClass map1.keySet()){
map2.put(a, map1.get(a));
}
and
map2.putAll(map1);
Both these methonds don't work.