进阶day10-.static和transient在序列化中的区别与作用

This commit is contained in:
2026-03-23 16:42:56 +08:00
parent 822f7b4810
commit b6b5c8ab39
3 changed files with 5 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ public class Demo11 {
Student s = new Student("张三", 20);
//序列化将java对象保存到文件中
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("student.txt"));
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("student2.txt"));
oos.writeObject(s);
oos.close();