This question is related to How do I copy a 2 Dimensional array in Java?
But how would you copy an array using streams in Java 8 / 9?
This is what I came up with:
static int[][] cloneArray(int[][] array) {
return IntStream.range(0, array.length).collect(
() -> new int[array.length][],
(ints, i) -> ints[i] = array[i].clone(),
(ints, i) -> {});
}
Is there a more elegant or performant way to copy a 2D array using streams?