D.4. Declaring Methods with Multiple Parameters
We now consider how to write your own methods with multiple parameters. Figure D.2 uses a method called
maximum to determine and return the largest of three
double values. In
main, lines 14–18 prompt the user to enter three
double values, then read them from the user. Line 21 calls method
maximum (declared in lines 28–41) to determine the largest of the three values it receives as arguments. When method
maximum returns the result to line 21, the program assigns
maximum’s return value to local variable
result. Then line 24 outputs the maximum value. At the end of this section, we’ll discuss the use of operator + in line 24.
1 // Fig. D.2: MaximumFinder.java 2 ...