> Is it possible to override a static method ? if so,
> how? if not why?
The question of what you can do in Java is determined by the Java Language Specification.
The question of how the JLS came up with its decision is explained in The Java Programming Language by Gosling and others. This is where you find explained why Java is this the way it is. Get this book if you're a serious student of Java.
friends ...
you have mentioned so far, that we can not override a static method.
but in java tutorials,http://java.sun.com/docs/books/tutorial/java/IandI/override.html
they have mentioned we can override a superclass static method. but they call it as method hiding.
pls. clarify....
> tutorials,http://java.sun.com/docs/books/tutorial/java
> /IandI/override.html
> they have mentioned we can override a superclass
> static method.
No, they don't mention that at all. What they do mention is that "defining a class method with the same signature as a class method in the superclass" is overriding for instance methods, and hiding for class methods.
They go on to explain the difference. The part after "The distinction between hiding and overriding has important implications."
> they have mentioned we can override a superclass static method. but they call it as
> method hiding.
No - in the section "Class Methods" they describe "a class method with the same signature as a class method in the superclass" as hiding. They go on to note "The distinction between hiding and overriding has important implications." (emphasis added), then go on to detail the distinctions.
The version of the overridden method that gets invoked is the one in the subclass. The version of the hidden method that gets invoked depends on whether it is invoked from the superclass or the subclass....
==========
the above is from the java tutorials.
can anyone pls. explain this..