- A getter's purpose is to allow access to an attribute (instance variable) from outside of the class.
- This is needed because your instance variables are declared private (make sure you do it in all the rest of the code you turn in).
- This means they can only be accessed from within the class.
- Once you have declared your instance variables, the basic getters "write themselves" in that in most cases, all the information you need to know to write a getter can be derived from the declaration of the corresponding instance variable.
- Here is the syntax for every basic getter:
public DataTypeOfInstanceVariable getInstanceVariable()
{
return instanceVariable;
}