List 转为 Map<id, bean> User是List对象的元素,List<User> List对象的变量名为:userList id 将作为 Map 的 Key Map<String, User> idMap = userList.stream().collect( Collectors.toMap