我们知道每个类都从Object扩展,这意味着我们可以在任何类中使用所有Object的方法.我的问题如下:
interface B{
}
public class A implements B{
public static void main(String[] args){
B i = new A();
i.display();//we can't do this : because the interface B doesn't define such a method
System.out.println(i.toString());// we can do this although the interface doesn't extend from Object
}
public void display(){
}
}
Run Code Online (Sandbox Code Playgroud)
所以我认为问题很明显,为什么我可以调用toString方法虽然接口B不能从Object扩展?
| 归档时间: |
|
| 查看次数: |
60 次 |
| 最近记录: |