Codehs 8.1.5 Manipulating 2d Arrays 〈iPhone〉
return matrix;
Many students assume 5x5 or 4x4. Always use matrix.length and matrix[0].length so your code works for any rectangle. Codehs 8.1.5 Manipulating 2d Arrays
The final value must be the number of rows in the 2D array (the length of the outer array). return matrix; Many students assume 5x5 or 4x4
💡 It is very common to swap the row and column variables. Always use the format array[row][column] . r++) for (int c = 0
Here is a typical you might see:
for (int r = 0; r < array.length; r++) for (int c = 0; c < array[r].length; c++) // Logic goes here // Access element using: array[r][c]
The goal is to test your ability to navigate nested loops and access elements using array[row][col] syntax.