Brian Kellytt wrote:Sorry Jesper, the Driver or testing class is the class that contains main.
Ah, OK. Well in that case the answer is: because you don't need to. The only thing that your definition of a "driver" class should contain is a
main() method with either one or two lines in it. No other methods, and
certainly no variables.
For a couple of
patterns, have a look at the
MainIsAPain page.
Should I forget protected altogether then?
No, but you should only use it when there's a real need - ie, when you want something visible to subclasses (the package visibility is a bit of a red herring, since you normally use
protected for
subclass visibility).
And, tempting as it may seem to use it on variables, I generally only use it with methods. If I need a
variable to only be visible to subclasses, I'll usually provide a
protected getter (and possibly a setter too; but ONLY if it's needed).
HIH
Winston