deep-copy

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

这一生的挚爱 提交于 2019-11-25 21:36:49
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. What is the difference between a deep copy and a shallow copy? 回答1: Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements. Deep copies duplicate everything. A deep copy of a collection is two collections with all of the