1

Possible Duplicates:
Why can’t static methods be abstract in Java
Static methods and their overriding
Why doesn’t Java allow overriding of static methods ?

Can we override static method in Java?

Community
  • 1
  • 1
  • See also http://stackoverflow.com/questions/2223386/why-doesnt-java-allow-overriding-of-static-methods – nos Jul 01 '10 at 12:52

2 Answers2

4

No. Static methods are tied to the class they're defined in. They're invoked through the class, not through an object, and there is no dynamic dispatch where overriding could happen.

You're probably confused because Java allows you to invoke static methods through an object reference. That's generally considered a design error, and it does not work like invoking instance methods, because the compile-time type of the reference decides which method gets invoked.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
0

No, but you can shadow it.

duffymo
  • 305,152
  • 44
  • 369
  • 561