mengw

有很多时候我们会遇到这样的场景,就是要将一个list中的某一个元素中的某一属性单独拿出来放在一个新的list里面,这中时候,我们就可以用以下的方法来进行实现:

List<Bean> items = new ArrayList<>();
List<String> collect = items.stream().map(Bean::getName).collect(Collectors.toList());

这样我们就获取到了Bean中的name的一个list。

相关文章:

  • 2020-10-08
  • 2021-08-07
  • 2021-08-12
  • 2021-11-05
  • 2019-03-08
  • 2021-12-03
  • 2021-10-16
  • 2019-12-26
猜你喜欢
  • 2020-11-09
  • 2021-12-09
  • 2021-12-03
  • 2021-07-30
  • 2021-12-03
  • 2021-12-03
相关资源
相似解决方案