This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes shallow cloning and deep cloning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "shallow cloning and deep cloning " Watch "shallow cloning and deep cloning " New topic
Author

shallow cloning and deep cloning

Aaron Raja
Ranch Hand

Joined: Jun 07, 2007
Posts: 206
What is the main difference between shallow cloning and deep cloning of objects?


Thanks, AR
SCWCD 5, SCJP 1.4, OCA (PL/SQL)
Steve Wink
Ranch Hand

Joined: May 13, 2002
Posts: 223
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: shallow cloning and deep cloning