我正在尝试获取属于给定项目列表的组件列表.
由于我开始使用流,我无法弄清楚如何做到这一点.
projects.stream()
.map(p -> p.getComponents())
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
由于Project.getComponents()返回Collection<ProjectComponent>前一个代码将返回一个List<Collection<ProjectComponent>>然而我想返回一个List<ProjectComponent>我该怎么办呢?
亲切的问候.