我试过this StackOverflow的答案的代码,但我得到的错误Cannot infer type argument(s) for <R> map(Function<? super T,? extends R>)
:如何将2D数组转换为带有数据流的2D列表?
//data is int[][]
Arrays.stream(data)
.map(i -> Arrays.stream(i)
.collect(Collectors.toList()))
.collect(Collectors.toList());
没有理由将代码更改为'IntStream.of'; 'Arrays.stream'工作正常。 OP的代码中缺少的是调用'boxed()'... – Holger