How are constructors called during serialization and deserialization?

前端 未结 6 1419
感情败类
感情败类 2020-11-28 06:16

How are the constructors called during serialization and deserialization

  1. When there is one class implementing serializable?
  2. When there is parent/child
6条回答
  •  一个人的身影
    2020-11-28 06:27

    The deserialization process does not use the object's constructor - the object is instantiated without a constructor and initialized using the serialized instance data. The only requirement on the constructor for a class that implements Serializable is that the first non-serializable superclass in its inheritence hierarchy must have a no-argument constructor.

提交回复
热议问题