Questions tagged «static-binding»

9
静态与 Java中的动态绑定
我目前正在为我的一个类进行分配,在其中,我必须使用Java语法给出静态和动态绑定的示例。 我了解基本概念,即静态绑定在编译时发生,而动态绑定在运行时发生,但是我无法弄清楚它们是如何实际工作的。 我找到了一个在线静态绑定的示例,给出了以下示例: public static void callEat(Animal animal) { System.out.println("Animal is eating"); } public static void callEat(Dog dog) { System.out.println("Dog is eating"); } public static void main(String args[]) { Animal a = new Dog(); callEat(a); } 而且这将显示“ animal is eating”,因为对的调用callEat使用了静态绑定,但是我不确定为什么将其视为静态绑定。 到目前为止,我所见过的任何资料都没有设法以我可以遵循的方式来解释这一点。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.