Accessor and Mutator Methods

Accessor method: does not change the object

  double width = box.getWidth();

Mutator method: changes the data of the object

  box.translate(15, 25);
//moves the rectangle by 15 units in x-direction and 25 in y.

Accessor method views the data of an object
while mutator method
updates the data of an object.

Think:

Look at String class.  There are three methods that we have seen.
They are length(),replace(), and toUpperCase().
Is each of them accessor or mutator?

Methods include:
1. the action that the method carries out.
2. the parameters that the method receives.
3. the value that it returns (or void - no value to return)

of Rectangle class