View RSS Feed

Java Basic

Shallow cloning Vs Deep cloning

Rate this Entry
by , 01-08-2012 at 12:36 PM (4169 Views)
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 faster deep cloning and easy to maintain.

Name:  57.JPG
Views: 1289
Size:  22.2 KB

Shallow cloning Vs Deep cloning

Submit "Shallow cloning Vs Deep cloning" to Facebook Submit "Shallow cloning Vs Deep cloning" to Digg Submit "Shallow cloning Vs Deep cloning" to del.icio.us Submit "Shallow cloning Vs Deep cloning" to StumbleUpon Submit "Shallow cloning Vs Deep cloning" to Google

Comments