I have a requirement to have a backup copy of orginal HashMap so that when some deletion,addition is done on original HashMap I can use a backup Map to track it
Gaurav Chikara wrote:I am not able to have a backup copy as whenever something happens to original copy backup copy is also getting affected with same operation
If anyone can please help as I am really stuck
Well, it depends on what you mean by "something happens". If you mean that the items get deleted or added, then it should work -- meaning that your clone will have the old structure.
If you mean changes to the key or value, then it won't work -- as the clone is only a shallow copy. You will need to copy it (via a loop, and possibly recursively), if you want a deep copy.