I have some code which creates an ArrayList of HashMaps, I then need a copy of that ArrayList of HashMaps for performing calculations, but I want the original to stay the same.
I have tried all sorts, from people's SO answers, here's my current code:
List<Map> counts = new ArrayList<>();
The counts
list is filled with HashMaps.
I need a copy of that but I don't want the calculations I perform on the copy to affect the original.
I have tried:
List<Map> copyCounts = new ArrayList<Map>(counts);
But whenever I perform changes it alters the original