What is the difference between a shallow copy and a deep copy? - ProProfs Discuss
Advertisement

What is the difference between a shallow copy and a deep copy?

Asked by Wyatt Williams, Last updated: Jun 06, 2024

+ Answer
Request
Question menu
Vote up Vote down

2 Answers

H. Jones

H. Jones

H. Jones
H. Jones, Web Content Writer, San Antonio,

Answered Sep 20, 2018

A shallow copy will get the information from the selected field values but it may lead to a result that you do not want as the memory it points to will not be included. A deep copy, on the other hand, will be able to point to the memory that you would like to get. In other words, a shallow copy is only a clone but a deep copy will be able to produce results.

It will depend on you and the actions that you are doing to choose which type of copy you would use. They are both useful for various purposes. Take note that a deep copy and a shallow copy is different from object copy which simply means copying the object perse.

upvote downvote
Reply 

satpathy.ruman

satpathy.ruman

satpathy.ruman
Satpathy.ruman

Answered Jan 30, 2017

Shallow copyis a bit-wisecopyof an object. A new object is created that has an exactcopyof the values in the original object. If any of the fields of the object are references to other objects, only the reference addresses arecopiedi.e., only the memory address iscopied.
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.