返回类型和多重继承?

Cha*_*har 1 java interface multiple-inheritance

interface i1{
    int test();
}

interface i2{
    String test();
}

class Test implements i1,i2{
    <Return type> test(){
         //code here
    }
}
Run Code Online (Sandbox Code Playgroud)

如果实现方法的返回类型为int,则错误表示返回类型与i2.test()不兼容 如果实现方法的返回类型为String,则错误表示返回类型与i1.test()不兼容

我应该如何在我的类Test中实现这两个接口

任何帮助都很明显.

dty*_*dty 8

你不能.他们是不相容的.在这种情况下,只考虑方法名称和参数.

你的选择是:

  1. 更改其中一个方法的名称
  2. 使参数列表不同包含不同的类型