Object cloning means creating a copy of an object. There are various means of doing this. Most common are Copy Constructors and Cloning. Cloning is done mostly so the copy can be modified or moved, or the current value preserved. If either of these is unneeded, a reference to the original data is sufficient and more efficient, as no copying occurs....

Read More

In Java there is a clone() method declared in the Object class. The objective of this method is to clone the calling object. However to use this method from any class, that class needs to implement the Cloneable interface else an Exception will be thrown at runtime (CloneNotSupportedException). clone() acts like a copy constructor. Typically it cal...

Read More

Java uses the clone() method to create a copy of an object. By default this copy is a shallow copy of the original object. To achieve deep copy you would need to make some changes in the class. Consider the image below. 1. Shallow copy : If a shallow copy is performed on the Obj-1 as shown in Img-1 then it is copied but it's containing objects are ...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself