import java.io.*;
class Person implements Serializable{
private String name;
private int age;
private String id;
}class Car implements Serializable{
private String brand;
private double price;
}
public class xulie {
public static void main(String[] args) throws IOException {
File file = new File ("C:\\Users\\LENOVO\\Desktop\\学生会\\new");
ObjectOutputStream oos=new ObjectInputStream
(new FileOutputStream((file));;
oos.writeObject(new Person("孙悟空",22,"430001"));
oos.writeObject(new Car("红旗汽车",250000));
oos.close();
}
}
Java学习打卡day20
最新推荐文章于 2024-07-12 16:26:30 发布