java 中具有相同函数原型的接口?

interfaces having same function prototype in java?

我已经在单个 class 中实现了两个具有相同方法名称和签名的接口,那么编译器将如何识别哪个方法适用于哪个接口?

E.X:

           public interface Hourly{
              int calculate_salary();
            }

           public interface Fixed{
              int calculate_salary();
            }

           public class Employee implements Hourly, Fixed{   
              public static void main(String... args) throws Exception{   

              }

              @Override
              int calculate_salary(){  // from which interface Hourly or Fixed???
                return 0;
              }
            }

此问题在 C# 中有解决方案,但在 java 中无法解决,请帮助

感谢

没有选择。

这个方法只能有一个实际实现,并且会被调用。 class 实现了两个接口,这两个接口都强制它具有这样的方法,但这并不意味着必须(或可以)有两个这样的方法。一个方法的存在满足两个接口强加的条件。