is that the first method returns a single int, while the second one returns an array of ints.
If you have a 2D array (in java that is an array of arrays, so where each element is an array itself) you can iterate through the rows as Norm showed you (and that is indeed called an enhanced for-loop)
or using a traditional loop:
My idea to solve your assignment is to have a method say
Now, create a 2D array int, name it solution, that has my2DArray.length rows. Then, for each row of my2DArray, invoke the method
and the array that this method returns will be the corresponding row of the solution. So the method 'changeLastElementOfAllRows' would look something like:
This way, we do not change our 2D input array, but return a completely new 2D array.
Think about it.
There are three kinds of actuaries: those who can count, and those who can't.