Setter
In short: A setter is a method that sets the value of a private attribute, usually with a check.
In more detail: It follows the naming rule setAttribute(value).
In Depth
private int age;
public void setAge(int age) {
if (age < 0) throw new IllegalArgumentException("negative");
this.age = age;
}The check protects against invalid states. See getter, this, private.
See also: Getter, Meaning of this, private