利用java8新特性,可以用简洁高效的代码来实现一些数据处理。
定义1个Apple对象:
public class Apple {
private Integer id;
private String name;
private BigDecimal money;
private Integer num;
public Apple(Integer id, String name, BigDecimal money, Integer num) {
this.id = id;
this.name = name;
this.money = money;
this.num = num;
}
}
添加一些测试数据:
Apple apple1 = new Apple(1,"苹果1",new BigDecimal("3.25"),10);
Apple apple2 = new Apple(1,"苹果2",new BigDecimal