| Author |
Difference between Shallow copy and Deep Copy in Java
|
Mahi Ranga
Ranch Hand
Joined: Jan 27, 2011
Posts: 33
|
|
Hi Sir/Mam,
Explain What is the Difference between Shallow copy and Deep Copy in Java.please provide some examples.
Regards,
Mahi.
|
 |
pegel van de Wiel
Greenhorn
Joined: Jun 09, 2011
Posts: 3
|
|
Allways wanted to do this
http://lmgtfy.com/?q=What+is+shallow+copy+and+deep+copy+in+Java%3F&l=1
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
Welcome to the Ranch
|
 |
Dan Din
Greenhorn
Joined: Jun 06, 2011
Posts: 12
|
|
|
Good one, Pegel!
|
 |
Dawid Skrzypczynski
Ranch Hand
Joined: Jun 08, 2011
Posts: 50
|
|
Hi,
- Shallow copy means copy only intermediate objects, pointers, references, handles etc and is created very fas.
- copies this object refer to the same object, change in its state will be visible in all copies of this object.
- deep copy means real object copy, it take more times and resources but object and his copy are independent of each.
- Object changes have no effect on the copies
Sorry for my English i know that is not perfect.
|
 |
pegel van de Wiel
Greenhorn
Joined: Jun 09, 2011
Posts: 3
|
|
Ok, had my fun, a little more constructive:
Dawid has said it all, but keep in mind, for the non fast (i.e. deep copy) make sure to implement Cloneable interface and override the clone() method.
|
 |
 |
|
|
subject: Difference between Shallow copy and Deep Copy in Java
|
|
|