I have a base-class called Element. Some other classes (like Label and Image) both extend this class.
I now have a dispatching class having the following methods:
public class Dispatcher {
public static AbstractPropertyEditor<Label> createEditor(Label e) {
...
}
public static AbstractPropertyEditor<Element> createEditor(Element e) {
...
}
}
If now I have an instance of Label (which extends Element) and I want to pass it to createEditor()
, why is the most generic method (the second one) called? Wouldn't it be normal that the most specific method (createEditor(Label e)
) is called?
I absolutely need the method with the Element-param in order to "catch" all those classes that a) implement Element but do not have their own specific method in this dispatching class..
I'm using Java 6, how to "fix" this?
Edit: Okay, I have to admit it's not at all about generics. But that's where I encountered it the first time.
thanks and regards
Label
notElement
? – SupernormalT extends Element
whereT
happens to beLabel
?) – Supernormal