6.4. Declaring Methods with Multiple Parameters

Chapters 35 presented classes containing simple methods that had at most one parameter. Methods often require more than one piece of information to perform their tasks. We now show how to write methods with multiple parameters.

The application in Fig. 6.3 and Fig. 6.4 uses a programmer-declared method called maximum to determine and return the largest of three double values that are input by the user. When the application begins execution, class MaximumFinderTest’s main method (lines 7–11 of Fig. 6.4) creates one object of class MaximumFinder (line 9) and calls the object’s determineMaximum method (line 10) to produce the program’s output. In class MaximumFinder (Fig. 6.3), lines 14–18 of method ...

Get Java™ How to Program, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.