【发布时间】:2018-02-06 18:21:07
【问题描述】:
所以可能有一个 abc 用于多次付款,现在我有:
//find abc id for each payment id
Map<Long, Integer> abcIdToPmtId = paymentController.findPaymentsByIds(pmtIds)
.stream()
.collect(Collectors.toMap(Payment::getAbcId, Payment::getPaymentId));
但后来我意识到这可能有重复的键,所以我希望它返回一个
Map<Long, List<Integer>> abcIdToPmtIds
其中一个条目将包含一个 abc 和他的几笔付款。
我知道我可能可以使用groupingBy,但我想我只能使用Map<Long, List<Payments>>。
【问题讨论】:
标签: java java-stream