salary field is not read-only, but it can only be changed by the
raiseSalary method. In particular, should the value ever turn out wrong, only that method needs to be debugged. Had the
salary field been public, the culprit for messing up the value could have been anywhere.
With a setter, object can restrict the value changes to a certain field with rules. This can't be done if the field is public.
Share this highlighthttp://www.safaribooksonline.com/a/core-java-volume/3980144/