Java – what is better shallow or deep cloning?

I'm a little confused about object cloning in Java What is the main difference between shallow cloning and deep cloning?

Which one is better?

Solution

In shallow cloning, a cloned class does not copy its internal objects, but in deep cloning, all internal objects of the class are also copied One disadvantage of deep cloning seems to be serialization, which is not so easy to serialize cloned objects But we can't say which is better

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>