accessor and mutator methods gets and sets
Can someone tell me how accessor and mutator methods are called? I am looking at a sample project (there are three classes and too much code to post) where the set and get methods are never called. How does the program know to go to those methods? If there is a tutorial on this that someone knows about I would appreciate it. So far everything I read on accessor and mutators just shows code without explaining how it gets there or even why you need them. Thanks.
[471 byte] By [
pberardi1a] at [2007-11-27 9:51:57]

Here are a couple of tutorials. The general answer is that these methods are not called (see exception to this below) unless your code calls them. This first tutorial will walk you through the "HowTo" about field variables in Java. As a general rule field variables Java field variables have "private" scope, meaning that they cannot be accessed or set directly (this of course is fully based on what the programmer wants). If access to these field variables is required, "public" getter and setter methods are provided to accomplish this.
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/variables.html
Of course there is an exception to the "not called automatically" rule. When using JavaBean technology, the accessor methods seem to be called more automatically. Here is a tutorial on this technology.
http://java.sun.com/docs/books/tutorial/javabeans/