为什么会报错?谢谢
package com.imooc.CSDM;
interface One{
final int x = 11;
}
interface Two{
final int x = 22;
}
class Tree{
public int x = 33;
}
public class TestOne implements One,Two{
public void test(){
//无法判断是执行one当中的x 还是 执行two中的x;
//System.out.println(x);
//修改:
System.out.println(One.x);
System.out.println(Two.x);
}
public static void main(String[] args) {
new TestOne().test();
}
}
package com.imooc.CSDM;
interface One{
final int x = 11;
}
interface Two{
final int x = 22;
}
class Tree{
public int x = 33;
}
public class TestTwo implements One,Two{
public int x = 44;
public void test(){
System.out.println(x);
}
public static void main(String[] args) {
new TestOne().test();
}
}13
收起
正在回答 回答被采纳积分+1
Android零基础入门2018版
- 参与学习 人
- 提交作业 5461 份
- 解答问题 7235 个
此次推出的专题为Android攻城狮培养计划的第一部分语法与界面基础篇,将带大家从0开始学习Android开发。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星