I have the following recursive code that returns the array with 0"s (blanks):
public static int[][] llenarMatriz(int f, int c, int i, int j) {
int matriz[][] = new int[f][c];
if (i >= matriz.length) {
return matriz;
}
matriz[i][j] = 0;
j++;
if (j >= matriz[0].length) {
i = i + 1;
j = 0;
}
return llenarMatriz(f, c, j, j);
}
When I send you the dimensions, the following appears, any idea?
The place where I call the method, try to check the IF conditions when entering the array but it's not that, any ideas?, maybe an Exception?
When you implement recursion, think about the cases that will make it terminate, if there are none or they are wrong, the function will be called many times and will produce the error.
For your case the recursive function could be like this: