

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Information on the organization of 2d arrays in memory, as well as instructions for writing methods to get rows and columns in csis 110. Additionally, there is a lab assignment (lab 23) that requires writing a method to find the maximum value in each row of a 2d array and return it as a one-dimensional array.
Typology: Study notes
1 / 2
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.