code: public Matrix getMatrix(int i0, int i1, int j0, int j1)
      {
          Matrix X = new Matrix(i1 - i0 + 1, j1 - j0 + 1);
          double[][] B = X.getArray();
          try
          {
              for (int i = i0; i <= i1; i++)
              {
                  for (int j = j0; j <= j1; j++)
                  {
                      B[i - i0][j - j0] = A[i][j];
                  }
              }
          }
          catch (ArrayIndexOutOfBoundsException e)
          {
              throw new ArrayIndexOutOfBoundsException("Submatrix indices");
          }
          return X;
      }
docs: Get a submatrix.
  
  @param i0 Initial row index
  @param i1 Final row index
  @param j0 Initial column index
  @param j1 Final column index
  @return A(i0:i1, j0:j1)
  @throws ArrayIndexOutOfBoundsException Submatrix indices