思路类似我们编程,不会每次都重新写代码,而是修改以前的代码。
Instead of creating a new object, clone an exist object, then modify its properties.
Benefit: when creating process is very complex, such as database read, big network traffic.
overload clone method.
When the cloned object has sub objects
shallow clone: only copy references of those sub objects: super.clone()
deep clone: make a new copy of each sub object: new()
Instead of creating a new object, clone an exist object, then modify its properties.
Benefit: when creating process is very complex, such as database read, big network traffic.
overload clone method.
When the cloned object has sub objects
shallow clone: only copy references of those sub objects: super.clone()
deep clone: make a new copy of each sub object: new()