Number[][] intArray = new Integer[][]{ {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
double[][] doubleArray = Arrays.stream(intArray)
.forEach(pArray -> Arrays.stream(pArray)
.mapToDouble(d ->d.doubleValue())
.toArray())
.toArray();
I want to convert a Number[][] to double[][]. The above lambda does not work, the outer toArray does not compile.
Arrays.stream(intArray) : Returns a stream of Integer[]
forEach : For every Integer[], creating a stream of Integers, converting each Integer into double and returning a double[].
The for each creates the double[] and I thought the outer toArray would return an array of this double[]
How can I get this to work?