第一步 新建一个类继承Serializable接口
public class Goods implements Serializable{
private String goodsId;
private String goodsName;
private double price;
public String getGoodsId() {
return goodsId;
}
public void setGoodsId(String goodsId) {
this.goodsId = goodsId;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public Goods(String goodsId, String goodsName, double price) {
super();
this.goodsId = goodsId;
this.goodsName = goodsName;
this.price = price;
}
@Override
public String toString() {
return " [商品编号=" + goodsId + ", 商品名称=" + goodsName + ", 商品价格=" + price + "]";
}
}
第二步:新建测试类 对上一个类进行读写操作