Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Java by (10.2k points)

In java, it's a bit difficult to implement a deep object copy function. What steps do you take to ensure the original object and the cloned one share no reference?

1 Answer

0 votes
by (46k points)
edited by

A reliable method is to serialize the article, then deserialize. This assures everything is a source.

Here's an article on how to prepare this efficiently.

Want to learn Java from scratch? Here's is the right video for you on Java provided by Intellipaat:


Caveats: Properties can revoke serialization so that distinct cases are non designed, e.g. for singletons. Besides this of the sequence doesn't operate if your classes aren't Serializable

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
...