Question: Write a program that has a method called printArray to print a 2D array. The method will take in a 2D array and print the
Write a program that has a method called printArray to print a 2D array. The method will take in a 2D array and print the array in a grid fashion. Note: you can assume that the 2D array is not a ragged 2D array (e.g. it is a true grid). Method header public static void printArray (int [II] arr) Hint To get the number of rows in a 2D array (called arr): int row = arr.length To get the number of columns in a 2D array(called arr): int col = arrfol.length You will test your method in the main method of your program by using a Scanner: Read in two integers (R and C) that represents the rows and columns of a 2D array Then read in (RC) integers and copy the values into the 2D array Print the 2D array calling printArray Sample Input (read 2 ints: row and col; then read in a sequence of integers to be stored in the 2D array) 3 3 1 2 3 4 5 6 7 8 9 Sample Output 123 456 7 8 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
