- 使用java Stream流打印二维int数组
Arrays.stream(arr).map((int[] line)-> Arrays.stream(line).boxed().collect(Collectors.toList()))
.forEach(System.out::println);
- 使用java Stream流打印二维int数组,带行号
AtomicInteger index = new AtomicInteger();
Arrays.stream(arr).map((int[] line)-> Arrays.stream(line).boxed().collect(Collectors.toList()))
.forEach(e -> System.out.println(index.getAndIncrement() + ": " + e));
- 使用java Stream流将二维int[][]数组转换为List<List>
List<List<Integer>> collect = Arrays.stream(arr).map((int[] line) -> Arrays.stream(line).boxed().collect(Collectors.toList()))
.collect(Collectors.toList());