假设我得到了这个接口A:
interface A
{
void doThis();
String doThat();
}
所以,我想要一些抽象类来实现方法 doThis() 而不是 doThat() 方法:
abstract class B implements A
{
public void doThis()
{
System.out.println("do this and then "+ doThat());
}
}
abstract class B2 implements A
{
public void doThis()
{
System.out.println(doThat() + "and then do this");
}
}
当您最终决定在常规类中实现 de doThat 方法时会出现错误:
public class C implements B
{
public String doThat()
{
return "do that";
}
}
此类导致我出现上述错误:
“类型 B 不能是 C 的超接口;超接口必须是接口”
如果这个类层次结构是有效的,现在任何人都可以,或者我应该采取其他方式吗?