Accessors (Getters):
- Retrieve the value of a private field.
- Named as
getFieldName
.
Mutators (Setters):
- Modify the value of a private field.
- Named as
setFieldName
.
Example:
Benefits:
- Encapsulation and controlled access.
- Allows validation in setters.
- Follows JavaBean conventions.