File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

shallow copy and deep copy

 
aakash bhatt
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between shallow copy and deep copy
Regards,
aakash
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hi,
shallow copy:
you only copy the reference to an object
deep copy:
you copy the state of an object to a different object.
Olli
 
Gaurav Mac Mathur
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to be more eloberate if a Object A holds a refrence to another object B.
In shallow copy when the parent object A is copied in some new variable A1. A and A1 will hold the same refrence of B.
In deep copy the Object is also copied to a new Object when Copy of A is Made.
This is normally taken care by the Clone method.
This is why is is Advicable for every object to have
equals, clone , toString
methods.....
Cheers
Gaurav.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic