Java 8 lambda create list of Strings from list of objects

前端 未结 4 1193
自闭症患者
自闭症患者 2021-02-02 10:31

I have the following qustion:

How can I convert the following code snipped to Java 8 lambda style?

List tmpAdresses = new ArrayList

        
4条回答
  •  伪装坚强ぢ
    2021-02-02 10:41

    One more way of using lambda collectors like above answers

     List tmpAdresses= users
                      .stream()
                      .collect(Collectors.mapping(User::getAddress, Collectors.toList()));
    

提交回复
热议问题