为什么会报错?谢谢
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 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积分~
来为老师/同学的回答评分吧