Cloning Objects
Home ] Up ] What is Inheritance? ] Inheritance versus Containment ] Superclasses & Subclasses ] Visibility Modifiers & Inheritance ] Final Classes & Methods ] Polymorphism ] Data Hiding & Encapsulation ] Abstract Classes ] Interfaces ] [ Cloning Objects ] The Collections Framework ] Interfaces & Callbacks ]

 

The clone() method
Implementing clone()
The Cloneable Interface
Fixing Shallow Copies

 

Sometimes, you'll find it convenient to make an exact copy of an object instance.  That is, produce another independent object of the same datatype, with all the attributes having the same values as the original.

This is called cloning an object.

You might think that this would be simple to do.

You'd be wrong!

 

This page was last modified on 02 October, 2007