坑一 :
List.stream().collect(Collectors.toMap(e->e.getMainSellerId(),e->e.getSlaveSellerId()));
map的key不能重复
例子:
public static void main(String[] args) {
List<UcSellerMasterSlave> masterSlaveList = Lists.newArrayList();
UcSellerMasterSlave masterSlave = new UcSellerMasterSlave();
masterSlave.setMainSellerId(60000619);
masterSlave.setSlaveSellerId(60000618);
masterSlaveList.add(masterSlave);
masterSlaveList.add(masterSlave);
Map<Integer, Integer> masterSalveMap = masterSlaveList.stream().collect(Collectors.toMap(e->e.getMainSellerId(),e->e.getSlaveSellerId()));
}
问题分析
toMap()函数重载:
未指定合并函数mergeFunction情况下,传入throwingMerger()返回BinaryOperator对象,当出