- 报错代码
List<InvestmentVo> sortedList = list.stream()
.sorted(Comparator.comparing(InvestmentVo::getEstdate).reversed())
.collect(Collectors.toList());
- 原因
list中的investmentVo.getEstdate()存在null的子项,修改:
List<InvestmentVo> sortedList = list.stream()
.sorted(Comparator.comparing(InvestmentVo::getEstdate, Comparator.nullsFirst(Comparator.naturalOrder())).reversed())
.collect(Collectors.toList());
- 参考 链接