快捷导航

改错题,恳请大神解决

代码如下:interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员2

System.out.println(x);//这里有歧义,因为你实现了接口又继承了类,这里单独的x可能是类里面的也可能是接口里面的System.out.println(A.x);//使用接口里面的ASystem.out.println(super.x);//使用父类里面的A
回复

使用道具 举报

System.out.println(super.x);
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP