How to implement the same interface multiple times, but with different generics? [duplicate]
- 阅读更多 关于 How to implement the same interface multiple times, but with different generics? [duplicate]
问题 This question already has answers here : How to make a Java class that implements one interface with two generic types? (9 answers) Closed 6 years ago . I have the following interface, which I want to implement multiple times in my classes: public interface EventListener<T extends Event> { public void onEvent(T event); } Now, I want to be able to implement this interface in the following way: class Foo implements EventListener<LoginEvent>, EventListener<LogoutEvent> { @Override public void