title: Add Elements of a 2-Dimensional Array using recursion
body: <p>Hey guys I am having problems writing this part of my code. I have to sum up the elements of this 2-dimensional array using recursion. I understand what I need to do but I am not understanding how to implement this to step through the array. I keep receiving errors. Could someone please help me out? </p>
  
  <pre><code>import java.util.Scanner;
  
  public class Main {
  
      public static void main(String[] args) {
  
          int[][] a;
          a = new int[3][4];
          int sum = 0;
  
          System.out.println("Enter 12 numbers: ");
          Scanner scan = new Scanner(System.in);
  
          for (int i = 0; i &lt; 3; i++) {
              for (int j = 0; j &lt; 4; j++) {
                  a[i][j] = scan.nextInt();
              }
          }
          sum = sum2D(a, 0, 0);
          System.out.println("The sum of the array: " + sum);
  
      }
  
      public static int sum2D(int a[][], int row, int col) {
          if (row == a.length-1) {
              return a[row][col];
          }
  
          if (col == a[row].length-1) {
              return a[row][col] + sum2D(a, row++, 0);
          }
  
          return a[row][col] + sum2D(a, row, col++);
      }
  
  }
  </code></pre>