某个字段值为字符串
List<User> userList = new ArrayList(); Map<String,String> collect = userList.stream().collect(Collectors.groupingBy( User::getRealname, Collectors.mapping(User::getUsername, Collectors.joining(","))));
某个字段值为list
List<User> userList = new ArrayList(); Map<String,String> collect = userList.stream().collect(Collectors.groupingBy( User::getRealname, Collectors.mapping(User::getUsername, Collectors.toList())));
标签:段值,Java,Stream,Collectors,collect,list,userList,User From: https://www.cnblogs.com/tdyang/p/17116964.html