Java 8 way to convert int[][] to Integer[][]

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 ?


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))

Leave a Reply

Your email address will not be published. Required fields are marked *