By scanning through the elements of the array, updating a provisional maximum until all elements have been examined. This is the algorithm used in the previous chapter.
The program shows a partial definition of the ArrayOps
class.
The ArrayOps
class contains a method findMax()
that
finds the maximum of an array.
The findMax()
method is static
,
which means that it is part of the class, not part of any object.
A static
method can be invoked without needing an object.
Look back to chapter 40 if you need to review this topic
(which has not been used much until now.)
The parameter list is of the method is: int[] x
x
which will be a
reference to an array object.x
to
stand for the actual array it will work with.
The parameter x
means
"whatever data is supplied when the method is invoked."
This may be different for different runs.
Fill in the blank so that the method is complete.