集合学习之"将集合对象List<Product>转换为Map"

将集合对象List<Product>转换为Map
  key = Product对象的sku
  value =Product对象

1 List<Product> products = productService.queryProductList(productQuery, null);
2 Map<String, Product> productMap = products.stream()
3         .collect(Collectors.toMap(Product::getProductSku, Function.identity(), (key1, key2) -> key2));

 

posted @ 2021-03-12 15:13  骚哥  阅读(318)  评论(0编辑  收藏  举报