implements GenericObserver<DataService, Tools>, GenericObserver<MobileService, Tools>
不能用不同的参数多次实现。
这是我的界面:
public interface GenericObserver<S, D> {
void update(S sender, D data);
}
我能做什么?我需要 DataService
和 MobileService
。
我尝试使用通用 T
而不是 DataService
和 MobileService
但我收到 T
的错误不存在。
最佳答案
这是因为 Java 在做 type erasure .编译后,所有通用类型都被删除,两个接口(interface)在字节码中看起来相同。
关于java - 接口(interface) xxx 不能用不同的参数多次实现 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13786770/