Find Maximum Method

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
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.

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.

QUESTION 2:

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