Accessor methods are your get() methods; they allow outside classes to access the private members of another class.
For example:
public class ClassA
{
private int number;
public ClassA(int theNumber)
{
number = theNumber;
}
//Now, we make a get() method for number, because it is private
//and cannot be accessed by other classes
public int getNumber()
{
return number;
}
}
public class ClassATest
{
public static void main(String[] heeheeNotCallingThisArgs)
{
ClassA test = new ClassA(5);
int cake = test.number; //This would throw an exception, since number is private
int otherCake = test.getNumber(); //This works, because getNumber() is public
}
}
Now, your modifier methods are your set() methods. I really have no clue why you'd want them to be private; this would mean that there's no way to edit the values in your class. Usually set() methods are public. Here's what a typical set() method looks like (using that previous class):
public class ClassA
{
private int number;
public ClassA(int theNumber)
{
number = theNumber;
}
public int getNumber()
{
return number;
}
//Now we'll add the modifier (set) method, so that number's value can be changed
public void setNumber(int newNumber)
{
number = newNumber;
}
}
public class ClassATest
{
public static void main(String[] heeheeNotCallingThisArgs)
{
ClassA test = new ClassA(5);
test.number = 2; //This would throw an exception, since number is private
test.setNumber(2); //This works, because setNumber() is public
}
}
Does that clear things up at all?