So I asked this question before, but I had an error in the code that most people chose, not the problem itself.
In any case, I'm trying to override the interface method in the class. However, I want the parameter type in the overriding method to be a subclass of the parameter type, as defined in the override method.
Interface:
public interface Observer { public void update(ComponentUpdateEvent updateEvent) throws Exception; }
While the class that overrides this method:
public class ConsoleDrawer extends Drawer {
ConsoleUpdateEvent is a subclass of ComponentUpdateEvent.
Now I could just use the update () method in ConsoleDrawer as the ComponentUpdateEvent parameter, and then pass it to ConsoleUpdateEvent, but if possible, I'm looking for a slightly more elegant solution. Anyhelp would be appreciated. Thanks.
java override generics parameters subclass
carnun
source share