

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
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Professor: Hanks; Class: Intro to Programming in Java; Subject: Computer Science Info Systems; University: Fort Lewis College; Term: Unknown 1989;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!
Reminders Program due today Homework due Monday Quiz Wednesday. Focus on nested for loops and 2D arrays. I strongly recommend going over the various examples in the forloop and twodim projects. Play around with the methods. Make sure you understand how they work. Tweak them slightly to make them work a little bit differently. Also javadoc, user-input validation, public/private. Last Time: Two-dimensional arrays Let's look at the TwoDim2 class (in two-dim project): What does the constructor do? What about the initializeArray method? Let's write a method getMax that returns the maximum value in the array. Let's write a method getRow to return the i'th row of the array.
Lab 21 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 one-dimensional array. Use a for loop to call this method for each row in the 2D array, filling in the one-dimensional array one element at a time. Email the file TwoDim2.java to me – use the subject "Lab 21"