//List里面的對象元素,以某個屬性來分組,例如,以id分組,將id相同的放在一起
//List 以ID分組 Map<Long,List<Sku>>
Map<Long, List<Sku>> mapList = skuList.stream().collect(Collectors.groupingBy(Sku::getProductSpecificationId));
System.out.println(mapList);
//List轉Map
Map<Long, Sku> appleMap = skuList.stream().collect(Collectors.toMap(Sku::getProductSpecificationId, item -> item));
System.out.println(appleMap);
//獲取 List 集合獲取指定的字段數組
List<Vip> vipList = new ArrayList<Vip>();
vipList.add(new Vip().setId(1L));
vipList.add(new Vip().setId(2L));
List<Long> idList = vipList.stream().map(Vip::getId).collect(Collectors.toList());
List轉換逗號分隔的字符串
StringUtils.join(productSpecificationIdList.toArray(), ",")
//Set轉List
Set<String> idSet = buyerCartMap.keySet();
List<Long> productSpecificationIds = Arrays.asList(idSet.toArray(new Long[idSet.size()]));