您需要将
collect自己的流放入列表:
List<String> adresses = users.stream() .map(User::getAdress) .collect(Collectors.toList());
有关其他信息,
Collectors请访问文档
User::getAdress只是
(User user) -> user.getAdress()可以写成的另一种形式
user ->user.getAdress()(因为类型
User将由编译器推断)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)