Object clone in Java
By default an object’s clone() yields a shallow copy. You must edit your class to get a deep copy of the cloned object.
• Shallow copy: As shown in figure, when an object is shallow copied, it does not copy its internal objects. Shallow cloning is supported by default in Java. Implement the interface java.lang.Cloneable to implement shallow cloning.
• Deep copy: In deep cloning, all the internal objects of the class are also copied as shown in figure below. Serialization supports