Shallow vs. Deep Object Copying

# Introduction A shallow copy will simply copy the values of the fields of the original object into the new object. In shallow copy, if the original object has any references to other class objects, then only the reference of that object is cloned. Therefore, any changes in this referenced object will be reflected in both the original and the cloned object. However, a deep copy creates a new object, including all referenced objects, and any changes made to the cloned object will not affect the original object.

|60 : 00

Click the virtual machine below to start practicing