Can I make a Template method in an Parent Class private
I want to use the template Pattern in overriding a method in a child class so when the method is called in the Parent Class, the overrided non in the Child Class is executed, But I am not sure which access modifier to use to declare the method in the Parent class, I want to make the Method private
or protected
if possible
You cannnot access the private
members of parent class. And if You make it protected
then you cannot access from the non-child classes outside the package.
So if you need to acces the method from anywhere use public
modifier. If you only need to access within the package use protected