我試圖谷歌這一個,但我找不到一個可以接受的答案。接口不一致,當你讓一個類實現2個或更多的接口,而這些接口是互不兼容的?例如:Java:什麼是接口不一致?
public interface Lion()
{
public void eat();
}
public interface Tiger()
{
public void eat();
}
public class Liger implements Lion, Tiger
{
public void eat(); //Problem: How does it eat? Like a lion or tiger?
}
我正確或離開基地?
不幸的是沒有直接的方法來解決這個問題。相關的主題:http://stackoverflow.com/questions/6211070/class-inheriting-from-several-interfaces-having-same-method-signature和http://stackoverflow.com/questions/2598009/method-name-collision -in-interface-implementation-java – adatapost 2011-12-16 02:56:52