有人说多继承会存在缺点:1.属性的歧义 2.方法的歧义。但接口也会有同样的问题啊,求高手详解!!!
interface AA
{
int a=9;
public int f1();}
interface BB
{
int a=99;
public double f1();
}
class Test implements AA,BB
{
public static void main(String[] args)
{
Test tt = new Test();
System.out.println(tt.a); //报错 歧义
}
@Override
public int f1() //报错The return type is incompatible with BB.f1()
{
return 0;
}
}
interface AA
{
int a=9;
public int f1();}
interface BB
{
int a=99;
public double f1();
}
class Test implements AA,BB
{
public static void main(String[] args)
{
Test tt = new Test();
System.out.println(tt.a); //报错 歧义
}
@Override
public int f1() //报错The return type is incompatible with BB.f1()
{
return 0;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货