less than 1 minute read

Shallow and deep copy

Shallow copies

It 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

It duplicate everything. A deep copy of a collection are two collections with all of the elements in the original collection duplicated.

Reference

Shallow and deep copy