下面提到的代码返回 A B A 作为输出,但我不明白为什么在 B 之后再次打印 A 的逻辑。
class A1 {
public A1() {
System.out.println("A");
}
}
class B extends A1 implements Serializable {
public B() {
System.out.println("B");
}
}
public class Test {
public static void main(String... args) throws Exception {
B b = new B(); // Object of class B
ObjectOutputStream objout=new ObjectOutputStream(new FileOutputStream("t.txt"));
objout.writeObject(b);
ObjectInputStream objin=new ObjectInputStream(new FileInputStream("t.txt"));
objin.readObject();
}
}