I'm wondering what is behind the Lint's advice of making the constructor of an abstract class protected?
Asked
Active
Viewed 85 times
2 Answers
4
Non-child classes can't call the constructor of an abstract class (it's not possible). The only classes that can call that constructor are children of the abstract class. Setting the constructor as protected only allows child classes to see the constructor.
Edit: For more information, see this question.
Also, Joop is correct about anonymous implementations (I didn't even know you could do that in Java). However, I have never seen anyone do that.

Community
- 1
- 1

supersam654
- 3,126
- 33
- 34
3
Seemingly to prevent anonymous implementations:
new AbstractClass() { ... };

Joop Eggen
- 107,315
- 7
- 83
- 138