Try It Yourself: arrays

  1. Complete the method sameShape that returns true if the two matrices have the same shape and false otherwise.  A matrix is simply a two-dimensional array of numbers.  Two matrices have the same shape if they have the same number of rows and corresponding rows have the same number of columns.
          public static boolean sameShape(int[][] matrixA, int[][] matrixB) {
          
          


  2. Write a code fragment that adds two integer matrices A and B and stores the result in matrix sum.  Recall that matrix addition is done element-wise, i.e. to find the value in row i, column j of A+B, just add the value in row i, column j of A and the value in row i, column j of B.  You may assume that A and B have been declared as int[][] and created.