Forums Register Login

Overriding

+Pie Number of slices to send: Send


I dont understand why "static final" prevent compilation?
+Pie Number of slices to send: Send
08. is an instance method and 04. is static. Its not overriding it. Just hiding it, right?
+Pie Number of slices to send: Send
@JJ
it's because you can't override static final methods .
+Pie Number of slices to send: Send
 

Jeet Jain wrote:

I dont understand why "static final" prevent compilation?



Forget about the final keyword for the moment. An instance method cannot "override" a static method. Similarly a static method cannot "hide" instance methods - only static methods.
Now assuming growFast() was static in Thistle, then the final keyword will come into play - it prevents the subclass static method from "hiding" the superclass static method.
+Pie Number of slices to send: Send
thank you:) got it
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 786 times.
Similar Threads
When a final is not a constant
jdbc statment creation
Overriding
how the execution happens?
interface example
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:33:05.