More on Arguments and Parameters

In Fig. B.3, displayMessage’s parameter list (line 7) declares one parameter indicating that the method requires a String to perform its task. When the method is called, the argument value in the call is assigned to the corresponding parameter (courseName) in the method header. Then, the method body uses the value of the courseName parameter. Lines 9–10 of Fig. B.3 display parameter courseName’s value, using the %s format specifier in printf’s format string. The parameter variable’s name (courseName in Fig. B.3, line 7) can be the same or different from the argument variable’s name (nameOfCourse in Fig. B.4, line 24).

The number of arguments in a method call must match the number of parameters in the parameter ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.