我可以给 2 个不同的类(我不能修改,因为它们是自动创建的 web 服务类)相同的接口吗?
问题:我有几个自动创建的 web 服务类,它们有一个具有相同签名的方法。但是由于这些类没有公共接口,我无法对它们进行分组,因此无法从一个方法中调用它们。
例子:
class A {
void sameMethod();
}
class B {
void sameMethod();
}
class MyService() {
//I cannot do the following as I cannot group A and B with the same interface
void callAorB(<Class A or B> object) {
object.sameMethod();
}
}
是否仍然可以执行 òbject.sameMethod() even though I cannot make a common reference between
class A and
class B`?