你可以使用Arrays.stream()方法将double[][][]转换为Stream<double[]>,然后使用collect()方法将其收集到一个List中。下面是一个示例代码:

double[][][] array = {{{1.0, 2.0}, {3.0, 4.0}}, {{5.0, 6.0}, {7.0, 8.0}}};

List<double[]> list = Arrays.stream(array)
        .flatMap(Arrays::stream)
        .collect(Collectors.toList());

这里的Arrays.stream(array)double[][][]转换为Stream<double[][]>,然后使用flatMap()将其扁平化为Stream<double[]>,最后使用collect()方法将其收集到一个List中。

这样操作可以避免出现Reference to 'toArray' is ambiguous, both 'toArray()' and 'toArray(IntFunction<A[]>)' match的错误

java stream 将double转Listdouble的正确操作且避免出现Reference to toArray is ambiguous both toArray and toArrayIntFunctionA match

原文地址: https://www.cveoy.top/t/topic/iFmP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录