Using Java, write a program that uses a method to output thecontents of a 2D array in a grid-based format.
Sampleoutput: 1 2 3 4 5
6 7 8 9 10
Solution
//Main.javapublic class Main { public static void print2D(int arr[][]){ for(int i = 0;i<arr.length;i++){ for(int j = 0;j<arr[i].length;j++){ System.out.print(arr[i][j]+”t”); } System.out.println(); } } public static void main(String args[]){ int arr[][] = {{1, 2, 3, 4,
OR
OR