Java12 Jun 2006 10:30 am
I’ve recently faced a problem with overriding static method. I wanted to do something like this:
[code lang="java"]
class A{
protected static void putUsefulInfo(InfoStorage storage){
storage.put(new Info("A"));
storage.put(new Info("B"));
storage.put(new Info("C"));
}
}
class B extends A{
protected static void putUsefulInfo(InfoStorage storage){
A.putUsefulInfo(storage);
storage.put(new Info("D"));
storage.put(new Info("E"));
}
}
[/code]
As a result, I figured out that in ordinary way it is impossible to use polymorphism. An overriden method is just hidden. I’m not going to paraphrase another useful articles, just visit them.
RESOURCES:
- Overriding and Hiding Methods
- Effective object-oriented design
- Overloading, Overriding, Runtime Types and Object Orientation – Overriding Methods
