-4

I have to write a method that prints values ​​in a matrix using recursion. When I try to compile the tester I get an error message:"cannot find symbol - method printMat(int[][])".

my Code:


public static void printMat(int ma[][]){
    printMat(ma,0,0);   
}

public static void printMat(int m[][], int i, int j){
    System.out.print("[" + m[i][j] + "]");
    if (i == m.length && j == m.length)
    {
        return;
    }

    if (j == m.length)
    {
        j = 0;
        ++i;
        printMat(m, i, j);
    }
    else 
    {
        j++;
        printMat(m, i, j);
    }
}

what am doing wrong?

Stephan Hogenboom
  • 1,543
  • 2
  • 17
  • 29
Idan D
  • 22
  • 3

2 Answers2

0

In java you define array parameters like so:

method(int[][] arr)

I'd recommend you reading java documentations and doing some basics tutorials first.

Levent Dag
  • 162
  • 8
-2

Where is the main method/ root method declared use:

public static void main(String[] args) {

}



public static void printMat(int ma[][]) {
            printMat(ma, 0, 0);
        }

        public static void printMat(int m[][], int i, int j) {
            System.out.print("[" + m[i][j] + "]");
            if (i == m.length && j == m.length) {
                return;
            }

            if (j == m.length) {
                j = 0;
                ++i;
                printMat(m, i, j);
            } else {
                j++;
                printMat(m, i, j);
            }
        }

J_D
  • 740
  • 8
  • 17
hemanth reddy
  • 457
  • 6
  • 15