Stream

生成Map

Map>

  1. List<User> userArrayList = new ArrayList<>();
  2. userArrayList.add(new User(1,"张三"));
  3. userArrayList.add(new User(1,"李四"));
  4. userArrayList.add(new User(2,"王五"));
  5. Map<Integer, List<User>> collect = userArrayList.stream().collect(Collectors.groupingBy(User::getAge));