Java – what is better shallow or deep cloning?
•
Java
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
二维码