Codehs 8.1.5 Manipulating 2d Arrays
The 2D length is the total count of all individual integers within the sub-arrays. You can find this by iterating through each row and adding the length of that row to a counter. length2D =
// Swap two columns by iteration public static void swapColumns(int[][] arr, int c1, int c2) for (int r = 0; r < arr.length; r++) int temp = arr[r][c1]; arr[r][c1] = arr[r][c2]; arr[r][c2] = temp; Codehs 8.1.5 Manipulating 2d Arrays
Treat each row as a single unit. Instead of swapping individual elements, we can swap the references (in Java) or loop through columns (in languages without pointer arrays). The 2D length is the total count of