• Post Reply Bookmark Topic Watch Topic
  • New Topic

explain deep copy and shalow copy in Java  RSS feed

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q1)Please explain deep copy and shalow copy in Java?

 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shallow copy creates a new instance of the collection, then copies only references to objects existing in 'old' collection (both old and new collections refer to the same objects).
Deep copy creates copies of objects in the collection and stores references to these new objects in new collection (new collection refer to 'fresh' copies of objects).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!