Arrays.streamwill go through int[]in int[][]. You can convert int[]to IntStream. Then, to convert the stream intto List<Integer>, you first need to put them. After you are boxed to Integers, you can put them on a list. And finally, we collect the stream List<Integer>into a list.
List<List<Integer>> list = Arrays.stream(data)
.map(row -> IntStream.of(row).boxed().collect(Collectors.toList()))
.collect(Collectors.toList());
Demo version
janos source
share