Back to all tasks

Find Maximum Element in Array

Implement the findMax method which takes an integer array as input and returns the largest element within that array.

If the input array is null or empty, the method should throw an IllegalArgumentException with the message "Array cannot be null or empty."

Example: findMax({1, 5, 2, 8, 3}) should return 8. findMax({-10, -5, -1}) should return -1.

find_maximum_element_in_array.java
Loading...

Use the "Verify Solution" button to get AI feedback on your java code.