java8 快速实现List转map 、分组、过滤等操作
点击上方“ 方志朋 ”,选择“ 设为星标 ” 回复” 666 “获取新整理的面试文章 来源:https://blog.csdn.net/lu930124/article/details/77595585 利用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<Apple> appleList = new ArrayList<>(); //存放apple对象集合 Apple apple1 = new Apple( 1 , "苹果1" , new BigDecimal( "3.25" ), 10 ); Apple apple12 = new Apple( 1 , "苹果2" , new BigDecimal( "1.35"