I have some data structures, and I would like to use one as a temporary, and another as not temporary.
ArrayList myObject = new ArrayList
Straightforward way to make deep copy of original list is to add all element from one list to another list.
ArrayList originalList = new ArrayList(); ArrayList duplicateList = new ArrayList(); for(Object o : originalList) { duplicateList.add(o); }
Now If you make any changes to originalList it will not impact duplicateList.