Mutator Methods
Introduction: 5.5.0
set method
s correspond with get methods to change the value of a private variable- also called
mutator methods
- these are
void
- take a
parameter
to change the private value
- also called
public class House {
private String address;
public void setAddress(String a) {
address = a;
}
}
Summary: 5.5.2
- a void method doesn’t return a value
- header contains
void
before the method name
- header contains
- a
mutator method
is a void method which changes the value of member variables
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
This was adapted from the CS Awesome curriculum, which was created by
Barbara Ericson, Beryl Hoffman, and many other CS Awesome contributors. All rights reserved.
CS Awesome is licensed under CC BY-NC-SA 4.0.