class - How do you make a deep copy of an object in Java? -


in java it's bit difficult implement deep object copy function. steps take ensure original object , cloned 1 share no reference?

a safe way serialize object, deserialize. ensures brand new reference.

here's article how efficiently.

caveats: it's possible classes override serialization such new instances not created, e.g. singletons. of course doesn't work if classes aren't serializable.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -