📄 test12.java
字号:
import java.io.*;
class B{
int i = 2;
B(int i) {
this.i = i;
}
B() {
}
}
class A extends B implements Serializable {
int x = 5;
A(int x) {
super(x);
this.x = x;
}
}
class Test12{
public static void main(String[] args) throws Exception{
File f = new File("a.txt");
ObjectOutputStream oos = new ObjectOutputStream(
new FileOutputStream(f));
oos.writeObject(new A(5));
oos.close();
ObjectInputStream ois = new ObjectInputStream(
new FileInputStream(f));
A obj = (A)ois.readObject();
System.out.println(obj.i);
ois.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -