I'm trying to convert a two dimensional int array to a single int where there is a space in between each number and a line break after each single array using streams.
I've done this easily for single dimensional arrays with mapToObj, but this does not when the stream consists of arrays instead of ints.
int[] a = {1, 2, 3, 4};
String[] strArray = Arrays.stream(a).mapToObj(String::valueOf).toArray(String[]::new);
String joined = String.join(" ", strArray);
a would map to 1 2 3 4 here. What I want would be to have something like
int[][] a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
map to
1 2 3
4 5 6
7 8 9
How can I get something similar to joined, but with two dimensional arrays and still using streams?