任何继承接口的类都必须实现在接口中声明的方法。不确定是否可能,但我想做的是以下操作:
interface test {
____ get();
}
class A extends test {
int val;
A(int x) {
val = x;
}
int get() {
return Val;
}
class B extends test {
String val;
B(String x) {
val = x;
}
String get() {
return Val;
}
是否可能有一个方法签名,能够返回两种不同的数据类型?