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

Answer:

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


Maximum-finding 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 is passed into the method as a parameter, and the maximum is returned by the method. The method is 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.


QUESTION 2:

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