Java: recommended solution for deep cloning/copying an instance

后端 未结 9 2432
半阙折子戏
半阙折子戏 2020-11-22 01:28

I\'m wondering if there is a recommended way of doing deep clone/copy of instance in java.

I have 3 solutions in mind, but I can have miss some, and I\'d like to ha

9条回答
  •  我寻月下人不归
    2020-11-22 02:01

    Depends.

    For speed, use DIY. For bulletproof, use reflection.

    BTW, serialization is not the same as refl, as some objects may provide overridden serialization methods (readObject/writeObject) and they can be buggy

提交回复
热议问题