Shallow Copying

Object copying can be performed as either "shallow" copying or "deep" copying. The difference between them lies in how nested objects are handled.

In shallow copying, a new object is created, but its internal elements (if they are also objects) remain references to the same objects as in the original. In other words, only references to the objects are copied, not the actual objects themselves.

Note that changes to nested objects will be visible in both the original and its shallow copy.

Comments (0)

Leave a comment