更新时间:2022-12-12 13:53:44
您可以使用 flatMap
使用单个 Stream
管道来完成:
You can do it with a single Stream
pipeline using flatMap
:
List<Integer> cats = goodsList.stream()
.flatMap(c->Stream.of(c.getFirstCategoryID(),c.getSecondCategoryID()))
.collect(Collectors.toList());