go to previous page   go to home page   go to next page


A parameter is data that is supplied to a method just before it starts running.

Find Maximum Method

find max machine

Say that we want a method that finds the maximum element in an array of integers. Think of this method as a machine that inputs an array and outputs the maximum.

The array will be passed into the method as a parameter, and the maximum will be returned by the method. The method will be a member of an object of the class ArrayOps (which we will write).

ArrayOps objects will have several useful methods as members. But for now let us work on just one method.


(Thought Question: ) How will the method determine the maximum of the array?