快,关注米兜Java,一起涨姿势~
热点推荐
- 深入浅出Nginx,如何做到高并发下的高效处理?如何做到热部署?
- 推荐27个Mybatis-Plus优秀案例
- foreach循环中为什么不要进行remove/add操作
- 微服务架构如何保证安全性?
学习目标
掌握java之Lambda函数式编程 filter、map等最常见用法。
实现前准备
利用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;
}
}
添加一些测试数据:
List appleList = new ArrayList<>();//存放apple对象集合
Apple apple1 = new Apple(1,"苹果1