Question: Write a method with the following header to return an array of integer values which are the smallest values from each row of a 2D

Write a method with the following header to return an array of integer values which are the smallest values from each row of a 2D array of integer values

public static int[] smallestValues(int[][] num)

For example, if the 2D array passed to the method is:

8 5 5 6 6

3 6 5 4 5

7 5 4 5 2

8 8 5 1 6

The method returns an array of integers which are the smallest values from each row as follows:

5

3

2

1

In the main method, create a 2D array of integer values with the array size 4 by 5 and invoke the method to find and display the smallest values from each row of the 2D array.

You can generate the values of the 2D array using the Math.random() method with the range from 0 to 9.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!