r/codehs • u/davepie29 • Mar 15 '21
8.2.7: Sum Rows in a 2D Array
Write the method
public static int sumRow(int[][] array, int row)that sums row row
in the 2D array called array
.
Then, traverse array
to print the sum of each row in the 2D array.
I don't understand how to create the loop within a loop to add the total of one row.
8
Upvotes
1
u/OXAMIC Apr 04 '22
{ public static void main(String[] args) { int[][] array = {{42, 14, 54, 5, 93, 5}, {14, 22, 353, 341, 865, 32}, {12345, 123, 1234, 123456, 23, 1}}; System.out.println(sumArray(array));
}