我用的java8
2017-12-29 本文已影响0人
smallcui
list to Map (java 8)
Map<String, String> collect = caBankTypeService.listCaBankType(new CaBankType()).stream().collect(Collectors.toMap(CaBankType::getBankUuid, CaBankType::getBankCenterName));
分组, 计数
Map<string long> result =
items.stream().collect(
Collectors.groupingBy(
Function.identity(), Collectors.counting()
)
);
排序
int arr[] = {1, 4, 2, 8, 5};
Arrays.parallelSort(arr);
for(int i : arr){
System.out.print(i + " ");
}
java 8 分区
Map<Boolean, List<CaCustomerCard>> collect = caCustomerCards.stream().collect(Collectors.partitioningBy(t -> t.getId() == cardId));