java.io.InvalidClassException: no valid constructor

后端 未结 3 732
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 12:50

When I run below program, I am getting exception as

java.io.InvalidClassException: Files.SerializationMain; Files.SerializationMain; no valid constructor
           


        
3条回答
  •  孤独总比滥情好
    2020-11-28 13:19

    Just provide default constructor in both classes (Parent & Child)

    During deserialization, the fields of non-serializable classes will be initialized using the public or protected no-arg constructor of the class. A no-arg constructor must be accessible to the subclass that is serializable. The fields of serializable subclasses will be restored from the stream. more

提交回复
热议问题