UNIVERSITY AT BUFFALO, THE STATE UNIVERSITY OF NEW YORK
The Department of Computer Science & Engineering
STUART C. SHAPIRO
: CSE 115 C
CSE 115
Introduction To Computer Science for Majors I
Lecture C
Lecture Notes #11
Stuart C. Shapiro
Spring, 2007
Mutator (Setter) Methods
Sets the value of an instance variable.
Method header includes formal parameters.
Formal parameters must be typed.
Formal parameters act like local variables in the method body.
Method call includes argument expressions.
When method is called, formal parameters are bound to values of corresponding actual arguments.
Note, two ways a variable can get a value:
Local variable: Be assigned a value in an assignment statement.
Formal parameter: Be bound to a value in a method call.
Accessor (Getter) Methods
Returns the value of an instance variable.
Copyright © 2007 by Stuart C. Shapiro. All rights reserved.
Last modified: Thu Oct 4 14:55:01 EDT 2007
Stuart C. Shapiro
<
shapiro@cse.buffalo.edu
>