People divide object copy in:
A shallow copy of an object s made by creating a new object whose fields point to the same objects as the old object.
A deep copy is made by creating a new object also for the objects pointed to by the fields, and perhaps for the objects they point to, and so on.
You may assume that you should use the clone method of Object, along with the Cloneable interface.
Unfortunately the design of this part of Java is not quite right, and it is very difficult to use it well.
So it is recommend that you implement your own method to clone. See Bloch’s book for an insightful discussion of the problem.
Copyright © 1998-2009 Dilvan Moreira