Java中可以使用Stream API的flatMap()方法来获取集合中的集合里的所有元素。例如:
List<List<Integer>> lists =Arrays.asList(Arrays.asList(1, 2, 3), Arrays.asList(4, 5, 6));
List<Integer> result = lists.stream().flatMap(Collection::stream).collect(Collectors.toList());
上述代码中,lists是一个包含多个子集合的集合,通过stream().flatMap(Collecti