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

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
Get step-by-step solutions from verified subject matter experts
