Preface: What is the difference between deep and shallow copies? 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, a shallow copy simply duplicates the object being considered, not the object it refers to. Deep copy: All variables of the copied object contain the same values as the original object, and the variables that refer to the object will point to the new object being copied, not the original referenced object. In other words, a deep copy copies the objects referenced by the object to be copied again.
Shallow Copy
A shallow copy is a value pass for the base data type, and a reference pass for the reference data type. The clone() method is used for both a shallow copy and a deep copy
On Java shallow copy and deep copy