第 20 节 对象序列化
import java.io.Serializable;
@SuppressWarnings("serial")
class Book implements Serializable { // 此类对象可以被序列化
private String title;
private double price;
public Book(String title, double price) {
this.title = title;
this.price = price;
}
@Override
public String toString() {
return "Book [title=" + title + ", price=" + price + "]";
}
}总结
最后更新于