Question: JAVA PLEASE Write maxOfArray , which takes in an array of integers and returns the largest integer within the array. If the array is empty,

JAVA PLEASE

JAVA PLEASE Write maxOfArray , which takes in an array of integers

Write maxOfArray , which takes in an array of integers and returns the largest integer within the array. If the array is empty, throw an IllegalArgumentException. Some examples: int testResult1 = maxOfArray(new int[] {1, 3, 4, 5, 2}); int testResult2 = maxOfArray(new int[] {-1, -3, -4, -5, -2}); System.out.println(testResulti); // should output 5 System.out.println(testResult2); // should output -1 maxOfArray(new int[] {}); // Should throw IllegalArgumentException

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!