标签:ora ems ali cti group slot get ping pap
1、分组并进行求和组合运算
示例主要代码:
List<String> items = Arrays.asList("apple", "apple", "banana", "apple", "orange", "banana", "papaya"); Map<String, Long> result = items.stream().collect( Collectors.groupingBy( Function.identity(), Collectors.counting() ) ); System.out.println(result);
运行结果如下:
{papaya=1, orange=1, banana=2, apple=3}
2、List转换成Map
示例主要代码:
Map<Long, AdSlotData> adPVNumMap = adSlotDataList.stream()
.collect(Collectors.toMap(AdSlotData::getSlotId, adSlotData -> adSlotData, (k1, k2) -> k1));
标签:ora ems ali cti group slot get ping pap
原文地址:https://www.cnblogs.com/kingsonfu/p/9859061.html