What is the difference between shallow copy and deep copy?

Q

What is the difference between shallow copy and deep copy?

✍: Guest

A

Shallow copy shares the same reference with the original object like cloning, whereas the deep copy get a duplicate instance of the original object. If the shallow copy has been changed, the original object will be reflected and vice versa.

2012-08-24, 2213👍, 0💬