When a function's argument is an object, the reference type is passed, and the operation inside the object function affects the outer object. If you want to pass a copy of an object, then you need to use the Clone () method of the objects. The Copy object returns a new object, not a reference; the difference between a copy object and a new object returned by the newly operator is that the Copy object already contains some information about the original object, not the object's initial information. When to use shallow clone (shallow copy, shadow copy), when to use deep clone (Dark copy): Mainly see what the nature of the specific domain object is, if it is the base type using shallow Clone, if it is reference Variable (reference variable) uses deep clone.
In clone, a shallow copy and a deep copy, a shallow copy is a direct call to Super.clone () for copying regardless of whether the parameter is a basic type or a reference type, and the resulting reference type still points to the same memory; deep copy is after calling Super.clone (). Also call the Clone () function of the reference parameter to copy it to achieve a deep copy.
Shallow copy:
(1) A basic data type (String) is a copy of a copy of a new object
(2) refers to an object or refers to the same object.
Clone of Java.lang.Object () deep copy, shallow copy