title: How to get sub-array of 2d array (matrix)
body: <p>I'm trying to get a sub matrix of a matrix, but I'm having difficulty with the logic behind it. For a matrix like this:</p>
  <pre><code>1 2 3 
  4 5 6
  7 8 9
  </code></pre>
  <p>I need to be able to get submatrix(A, 3, 2):</p>
  <pre><code>1 3 
  4 6 
  </code></pre>
  <p>This is what I've tried so far</p>
  <pre><code>    public Matrix submatrix(Matrix A, int i, int j) {
      Matrix subM = new Matrix(this.rows + 1, this.columns + 1);
      for (int r = i; r &lt; this.rows; r++) {
          for (int c = j; c &lt; this.columns; c++) {
              subM.data[r - i][c - j] = A.data[r][c];
          }
      }
      return subM;
  }
  </code></pre>
  <p>And this is how I'm trying to call it in main</p>
  <pre><code>Matrix A = new Matrix(new double[][]{{1, 2, 3},{4, 5, 6},{7, 8, 9}});
      int i = 3;
      int j = 2;
      Matrix m = A.submatrix(A, i, j);
      System.out.println(&quot;L:\n&quot; + m);
  </code></pre>
  <p>I'm new to java so I'd appreciate any help.</p>