An alternative to the deep copy technique

I have this task once where I have to deep copy a very complex object. I can't use Object.clone() since the Class is not implementing Cloneable and I just want to leave the Class alone. I found this solution which uses Java serialization to deep copy an object and lucky for me the object's Class implements serializable. The only drawback of this solution is its use of resources -- the process of serializing and deserializing takes much time compared to using Object's clone method.


About this entry


0 comments: