Write the method:
public int sumRow(int[][] matrix, int row)
that sums row row
in the 2D array called matrix.
Given:
You need to reference the second dimension of the array for j.
//ex: first dimension is matrix.length
//second dimension is matrix[any index in the first dimension].length
//and this cycle would continue with more and more [num] on the end
public int sumRow(int[][] matrix, int row)
{
int sum = 0;
for(int i = 0; i < matrix.length; i++)
{
for(int j = 0; j < matrix**[0]**.length; j++)
{
sum = sum + matrix[j][i];
}
}
return sum;
}