Deep Copy/Shadow Copy an Object in Java

Method 1: Implement Cloneable

Method 2: Creating a Copy constructor or copy factory

Method 3: Using Serializable

This method copy all of the object and instance inside the class. But I personally not suggest using this method because of the performance concerns. This method converts the object into a ByteArray and then convert it back into a new object.

We can also use apache utils to implement it:




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • How to debug MSVC in release mode
  • How to change the line endings in Linux
  • How to find the vc runtime version from an exe
  • How to debug local variable and lambda on c++ release build
  • Why auto is bad in c++