

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Quiz: next Wednesday Last time 2D arrays. Let's review the memory organization of a 2D array again. Let's look at TwoDim2 again
Lab 23 Write a method getMaxByRow in class TwoDim2. This method returns a one- dimensional array – the number of elements in the one-dimensional array is the same as the number of rows in the 2D array anArray. The method should set the value of each element of the one-dimensional array to the maximum value in the corresponding row of the 2D array. For example, if the 2D array is: 10 7 19 2 -3 5 0 8 12 4 8 - Then this method should return a one-dimensional array containing 3 elements: 19 8 12 Suggested approach: Write a private method getMax( int[] row ) that returns the maximum value in a row of the two-dimensional array. Recall that each row is a one-dimensional array. Use a for loop to call this method for each row in the 2D array. Store the return value in the appropriate element of a one-dimensional array, and return this array when it is full. Use the homework submission system (link on course web site) to turn in Lab 23.