The static and non-static methods have different signatures, and not simply because of the static
.
The non-static method is secretly taking an extra parameter - the value of this
.
If you're familiar with python, you can see this explicitly:
class SomeClass(object):
def doSomething(self):
pass // whatever method body
Here, the self
parameter is just a regular parameter: you can invoke the method and pass this parameter yourself.
In Java, it's sort of the same. When you invoke the doSomething
method, you implicitly pass one parameter to it, and that becomes this
.
However, the static method takes zero parameters. So actually, they aren't override-equivalent, and hence you aren't overriding the method correctly.
The JVM would have to somehow determine that the parameter should be discarded. The language could have been written to allow this, but the designers took the easier route of just disallowing it (because there's no good reason to use it anyway).