Aashish Pawar :
How to convert java
int[][]
to Integer[][]
? .It seems easy to convert single dimensional primitive array to Object type single dimensional array using java stream.
For example
Integer[] result = IntStream.of( intarray ).boxed().toArray( Integer[]::new );
Is there any way for two dimensional array like above ?
Michael :
You can do the same thing within a map
operation
int[][] twoDimenArray = {};
Integer[][] result = Stream.of(twoDimenArray)
.map(array -> IntStream.of(array).boxed().toArray(Integer[]::new))
.toArray(Integer[][]::new);