Here you can find the source of print2DIntArray(int[][] array)
public static void print2DIntArray(int[][] array)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static void print2DIntArray(int[][] array) { print2DArray(getBoxedInt2DArray(array)); }//from w w w . jav a 2s.c o m public static <T> void print2DArray(T[][] array) { if (array == null) { return; } int rows = array.length; System.out.println("["); for (int i = 0; i < rows; i++) { printArray(array[i]); } System.out.println("]"); } private static Object[][] getBoxedInt2DArray(int[][] nums) { if (nums == null) { return null; } Object[][] result = new Object[nums.length][nums[0].length]; for (int i = 0; i < nums.length; i++) { result[i] = getBoxedIntArray(nums[i]); } return result; } public static <T> void printArray(T[] array) { int len = array.length; System.out.print("["); for (int i = 0; i < len; i++) { if (i != len - 1) { System.out.print(array[i] + ", "); } else { System.out.println(array[i] + "]"); } } } public static Object[] getBoxedIntArray(int[] nums) { if (nums == null) { return null; } return Arrays.stream(nums).boxed().toArray(); } }