... pass a person’s name to the constructor’s name
parameter. The constructor will then assign the name
parameter’s value to the instance variable name
(line 9).
Parameter name
of Class Account
’s Constructor and Method setName
Recall from Section 3.2.1 that method parameters are local variables. In Fig. 3.5, the constructor and method setName
both have a parameter called name
. Although these parameters have the same identifier (name
), the parameter in line 8 ...
Get Java How to Program, Early Objects, 11th 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.