【发布时间】:2018-02-17 15:25:18
【问题描述】:
我有两个(非常没用的)interfaces 和 test1 扩展 test
interface test
{
int a = 8;
void show();
}
interface test1 extends test
{
int a = 4;
void show();
}
我有一个类MyClass(又有点没用)实现test1 接口
public class MyClass implements test1
{
public void show()
{
System.out.println(((test)this).a); // 1
System.out.println(test.a); // 2
}
public static void main(String ar[])
{
new MyClass().show();
}
}
在我提供的代码中,我有兴趣了解按 1. 排序的两个语句之间的语义差异(如果有的话)和2. 分别;因为结果是明智的,如果我错了,请纠正我,它们几乎是一样的。
【问题讨论】:
标签: java interface casting static this