It's been some time that I have been coding in
Java now... but I still keep thinking: 'How often do people use the
protected access modifier'. Typically, I just slam
private in front of my variables and provide
public accessor (setters and getters) methods to them. On a less frequent occurrence, I use
public access fields when I don't want to be bothered by setters & getters (because they do nothing more than just set and return the variables - in a simple project). I use
protected variables only rarely - mostly when I need subclasses to use a field in the superclass but don't want to have such field
public.
My question is 'How often do you use
protected variables? And in what scenarios (common/interesting) do you use them.