A mutator is also a type of method used in object-oriented programming languages to change the value of an instance variable.

For example, pretend that I have written a class which acts as a banking management program. In the constructor, I have set up the account balance, interest rate, how frequently interest is compounded, along with other things. These things have a particular value which the user does not assign to the variables... they are simply there as a template.

However, I can invoke the mutator method, which will allow for the user to change the set values of these variables. He could perhaps add more money to his balance.

so if I have this as my mutator:

public void setBalance(double amount)
{
balance = amount;
}

When I prompt the user to input the amount, it will create the balanace.

In order to invoke this method, you would type the name of the class followed by a period and the method name. So if this was part of a class called Accountant and I created an instance of Accountant called myAccount, I would type:

myAccount.setBalance(amount); somewhere in my static method.

Mutator methods are typically void, because they don't return any value, but can return the value of the variable within the method.