What is the main difference between shallow cloning and deep cloning of objects?
SCWCD 5, SCJP 1.4, OCA (PL/SQL)
posted 8 years ago
Originally posted by Aaron Rhena: What is the main difference between shallow cloning and deep cloning of objects?
Lets say you have an object which contains other objects which contain others etc. Basically, you have a complex tree of objects. A deep copy would go into each of these objects and create a copy of each of them. A shallow copy would copy the first ( outer ) object, and then copy references to the existing objects, rather than create copies of them.