I do know that when you make a method final
in java, it cannot be overridden.
When a method is private
, it can only be accessed by methods and members of that given class in which the method exists.
So, does it mean that since the method cannot be accessed it is no use trying to check if it can be overridden because I wrote the following declaration and I get the following warning :
private method addCode is declared final
private final void addCode(String code)
{
//codes here...
}
Well, private means no-one is going to access the method apart from you and final means no-one can overload the method. But since the only person with access to it is you, it makes no sense. You cannot be your own superclass.
It is like locking a document for writes whent the only person with the access to the file is you.
A private method cannot be overridden because it is not visible to child classes.
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