相关疑难解决方法(0)

使用相同的方法在类中实现两个接口.覆盖哪种接口方法?

两个具有相同方法名称和签名的接口.但是由单个类实现,那么编译器将如何识别哪个接口的方法是什么?

例如:

interface A{
  int f();
}

interface B{
  int f();
}

class Test implements A, B{   
  public static void main(String... args) throws Exception{   

  }

  @Override
  public int f() {  // from which interface A or B
    return 0;
  }
}   
Run Code Online (Sandbox Code Playgroud)

java overriding interface

223
推荐指数
6
解决办法
14万
查看次数

标签 统计

interface ×1

java ×1

overriding ×1