将ListBillExternalInfo externalInfos 用stream流 根据 某个字段 收集成MapLongListLong
可以使用stream流的collect方法结合Collectors.groupingBy来实现根据某个字段将List
Map<Long, List<Long>> resultMap = externalInfos.stream()
.collect(Collectors.groupingBy(BillExternalInfo::getField,
Collectors.mapping(BillExternalInfo::getId, Collectors.toList())));
上述代码中,使用Collectors.groupingBy方法将List
原文地址: https://www.cveoy.top/t/topic/iCQU 著作权归作者所有。请勿转载和采集!