flatMap:flatMap方法可用 Stream 替换值,然后将多个 Stream 连接成一个 Stream
图示例如下:
List<Integer> together = Stream.of(asList(1, 2), asList(3, 4))
.flatMap(numbers -> numbers.stream())
.collect(toList());
assertEquals(asList(1, 2, 3, 4), together);