my question is concerning about the "protected" access modifier.
I know its functionality, but I don't know when I need to use it. Conceptually methods in a class could be divided as: constructors setters/getters methods used from clients (i.e other classes) internal methods (used from other methods in the class)
You use protected when
abstract.Note that protected methods are similar to public methods in the sense that once you put them in, they need to stay in for as long as you support your library. Unlike private methods that you can freely remove, protected methods remain a part of the interface of your class.
Use it when you need to do some internal stuff that is not exposed in public API but still needs to be overriden by subclasses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With