Can anything be serialized as long as it implements Serializable?

前端 未结 3 841
余生分开走
余生分开走 2021-01-27 14:23

I\'ve already seen this: How to test in java that a class implements serializable correctly

I just have a more general question. If you create an object (say a circle) l

3条回答
  •  悲哀的现实
    2021-01-27 15:09

    Yes, it's all you need as long as the transitive closure of all the referenced objects are all serializable.

    Note this doesn't mean the deserialized object will actually work - that depends on the semantics of "Circle". The easiest way to lose out is becase the new object will be a copy, not the identical object.

提交回复
热议问题