interface Intf {
}
class A implements Intf {
}
class Test {
public static void main(String[] args) {
Intf obj = new A();
obj.toString();
}
}
Run Code Online (Sandbox Code Playgroud)
一位朋友给我看了这个代码,我无法向他解释......
我们知道'refer'对象中定义的方法只能在实例上运行.我们可以看到没有定义方法,Intf但是obj(where refer Intf)能够调用toString()Object.class的方法
我安慰他说一切都是Java中的对象(尽管我们在eclipse IDE中没有得到自动填充选项Intf)