2D arrays
int[][] grid = new int[3][4]; has 3 rows and 4 columns. grid.length is the number of rows; grid[0].length is the number of columns. Traverse with nested loops: row-major (outer loop over rows) or column-major.
int total = 0;
for (int r = 0; r < grid.length; r++) {
for (int c = 0; c < grid[0].length; c++) {
total += grid[r][c];
}
}
Recursion
A recursive method calls itself. It needs a base case that stops the recursion and a recursive call that moves toward it.
public static int factorial(int n) {
if (n <= 1) return 1; // base case
return n * factorial(n - 1); // recursive call
}