What is the difference between deep copy and shallow copy?

What is the difference between deep copy and shallow copy?

Shallow copy:

All variables of the copied object contain the same value as the original object, and all references to other objects still point to the
original object. In other words, shallow copy only copies the object under consideration, not the object it refers to.

Deep copy:

All variables of the copied object contain the same value as the original object. The variables that refer to other objects will point to
the new object that has been copied. Instead of the original referenced object. In other words, the deep copy will All the objects referenced by the object to be
copied are copied again

Guess you like

Origin blog.csdn.net/m0_51684972/article/details/109174761