Using Java Write Program Uses Method Output Contents 2d Array Grid Based Format Sample Out Q37125323

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

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.