“To allow suBTypes of non-serializable classes to be serialized, the subtype may assume responsibility for saving and restoring the state of the supertype's public, protected, and (if accessible) package fields. The subtype may assume this responsibility only if the class it extends has an accessible no-arg constrUCtor to initialize the class's state. It is an error to declare a class Serializable if this is not the case. The error will be detected at runtime. ” 也就是说,要为一个没有实现Serializable接口的父类,编写一个能够序列化的子类要做两件事情:
java.lang.Error: Unresolved compilation problem: Serializable cannot be resolved or is not a valid superinterface at Serial.SubC.<init>(SubC.java:15) at Serial.Test1.main(Test1.java:19) Exception in thread "main"