in java I am getting an out of bounds exception. working with 2-dim arrays. for(int r=0;r getRowTotal(a, (r+1))) { max=getRowTotal(a, r); rowNumber=r; } else max=getRowTotal(a, (r+1)); }

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

in java I am getting an out of bounds exception. working with 2-dim arrays. for(int r=0;r getRowTotal(a, (r+1))) { max=getRowTotal(a, r); rowNumber=r; } else max=getRowTotal(a, (r+1)); }

Computer Science
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

So, perhaps you should do a System.out.println(a.length); Which will show you the length of a. Also note that while your loop specifies r
here is what i switched it to: for(int r=0;r max) { max=getRowTotal(a, r); rowNumber=r; } }
getRowTotal method looks like this: public static int getRowTotal(int[][] a, int row){ int total = 0; for (int i = 0; i < a[row].length; i++) total += a[row][i]; return total; }

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Sorry, not sure if the problem was solved or not. Is it working now? Please note that your running getRowTotal twice. I would assign a variable to get the value and then if it's greater assign that to max rather than having to find the total multiple times. Just makes it a bit more efficient.
the array a doesn't have a (r+1)th element when r=a.length-1.
He changed it. It used to, then I commented and he changed it to the current version.
oh, ok my bad. broinjc probably followed up to post the final solution. i'd consider this one solved.

Not the answer you are looking for?

Search for more explanations.

Ask your own question