Very similar to getMin function
This getMax function in Listing
7 is very similar to the previously-discussed function named getMin
in Listing 6.
The main differences between the two functions are:
- This function begins with a trial value of -2147483648 in
a variable named max. This is the algebraically smallest value that
can be stored in an element of type long.
- During each iteration of a while loop, one element in the
array is compared to see if its value is algebraically greater
than the current value stored in max.
- If so, that value replaces the value in max.