* Creating 2D Arrays We looked at a few examples of methods that take 2D arrays as input and produce as a result 2D arrays that are generated based on the information in the input 2D arrays. Keep in mind that when the size of the 2D array is known in advance we can create a table of the given number of elements:int[][] myTable = new int[3][4]; // myTable has 3 rows of 4 columns of // empty cells (initialized to 0)Example: Replace the values in a region of a TableExample: Write a method replaceElements which takes a 2D array and returns a location (cenRow,cenCol) within the table and a size. The method then replaces all cells in the given region with a given value. For example: int[][] data = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 0, 1, 2}, {3, 4, 5, 6}, {7, 8, 9, 0} }; replaceElements( data, -1, 2, 1, 3 ); printTable( data ); cenCol V 1 2 3 4 update 3x3 region around cell (2,1) -1 -1 -1 8 cenRow > -1 -1 -1 2 -1 -1 -1 6 7 8 9 0This example illustrates how to setup the loops to process only a portion of the table. We are given the center of a region, so to find out where the region begins, we need to go up and down (for the rows) and left and right (for columns) by half the size. Here is the Java code:void replaceElements( int[][] table, int value, int cenRow, int cenCol, int size ) { for ( int r = cenRow - size/2 ; r <= cenRow + size/2 ; r++ ) { for ( int c = cenCol - size/2 ; c <= cenCol + size/2 ; c++ ) { table[r][c] = value; } } }Example: Using Nested Loops to Draw a Grid This was already done in Assignment 2 but the nested loop was hidden from view. Here we see it explicitly.void drawCirclesGrid( double startX, double startY, double radius, int numRows, int numCols ) { double curX = startX; double curY = startY; for ( int r = 0 ; r < numRows ; r++ ) { for (int c = 0 ; c < numCols ; c++ ) { canvas.drawCircle( curX, curY, radius, "red" ); curX = curX + 2*radius; } curX = startX; // need to go back to beginning of next row curY = curY + 2*radius; // go to next row } }