Question: Write the Java method below, which takes a two-dimensional array a of positive integers. The method returns the index of the row that has the

Write the Java method below, which takes a two-dimensional array a of positive integers. The method returns the index of the row that has the largest sum. Assume no two rows have the same sum. For example, if a is the array below, then row 0s values sum to 21, row 1s values sum to 19, row 2s values sum to 23, and row 3s values sum to 20. Since row 2 has the highest sum, the method would return the value 2.

0 1 2 3
0 5 10 1 5
1 1 2 1 15
2 8 7 5 3
3 6 1 12 1

--------------------------------------------------------------------------------------------------------------------

public static int indexOfHighestRowSum(int [][] a) {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!