今天遇到个业务代码中需要将一个集合对象中的某个属性抽出来成为一个集合,并取出最大值。(看代码)
这里用到几个api
java.util.Collections
java.util.stream.Collectors
List<LdbhdjDTO> dtoList = wisdomMapper.ldbhBySlfgl(year);
List<Integer> collect = dtoList.stream().map(LdbhdjDTO::getValue).collect(Collectors.toList());
Integer max = Collections.max(collect);