An accessor method is a method used to returns the value of the private member variable. They are also widely known as getter method.
A mutator method is a method used for controlling changes to a variable. Another name of a mutator method is setter.
The naming convention for accessor method is getDataFieldName() for non-boolean values and isDataFieldName() for boolean values, and the naming convention for mutator method is setDataFieldName(value). Here is an example from wiki:
Remarks
Text provided above does not means is the
model answer, and it's was posted here for an reference to somebody who
interested the related knowledge only. if there is something incorrect,
please leave a comment so that i can correct it or for others viewer to
have an better reference, if you want know more about this topic and
where is the question, concept or answer from, you can reference from
information provided under the reference sub-title.
Reference:
1) Introduction to Java Programming, Y. Daniel Liang
2) https://en.wikipedia.org/wiki/Mutator_method
No comments :
Post a Comment