Mutator Methods
Introduction: 5.5.0
set methods correspond with get methods to change the value of a private variable- also called
mutator methods - these are
void - take a
parameterto 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
voidbefore the method name
- header contains
- a
mutator methodis 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.