Private Instance Variables

When you work on the Band Booster component of the current assignment, you will see that the instance variablees of the BandBooster class are supposed to be declared as "private". E.g:

class BandBooster { private String name; ... etc....

I will explain why this is a good idea on Monday. For now, though, all you have to know is that a private instance variable can only be accessed in methods of the same class. So, for example, in BandBooster I might have a method such as:

public void setNameToBob() { name = "Bob";
}

Perfectly peachy. Consider, though, the other class you will write, SellCandy. The following would not work:

class SellCandy { public static void main(String[] args) { BandBooster bobEuffer = new BandBooster(); bobEuffer.name = "Bob Euffer"; // <=== won't work

The last line would not compile because you are trying to access the instance variable "name" of the BandBooster object bobEuffer. This is not allowed because name is a private instance variable of the BandBooster class and so can only be accessed by methods of the BandBooster class. The method "main" here is a method of the SellCandy class, not of the BandBooster class.