String[] words = new String[]{"Hello","World"}; List<String[]> a = Arrays.stream(words) .map(word -> word.split("")) .collect(toList()); a.forEach(System.out::print);
输出结果为两个array的地址
flatmap()
而如果使用flatmap()就可以将其转成同一维度
1 2 3 4 5 6
String[] words = new String[]{"Hello","World"}; List<String> a = Arrays.stream(words) .map(word -> word.split("")) .flatMap(Arrays::stream) .collect(toList()); a.forEach(System.out::print);