简体   繁体   English

动态绑定和动态加载有什么区别?

[英]What is the difference dynamic binding and dynamic loading?

I am confused with these concepts of object oriented programming. 我对这些面向对象编程的概念感到困惑。 Both are done at runtime but I am unable to differentiate the two. 两者都在运行时完成,但是我无法区分两者。

Dynamic binding and dynamic loading really are at the edge of the set of Java concepts needed for a dev, if not outside, since Java tries to generally spare you from such things. 实际上,动态绑定和动态加载处于开发人员所需的Java概念集的边缘(即使不是外部条件),因为Java通常会尝试使您免于此类事情。

Dynamic binding is a runtime lookup by name. 动态绑定是按名称进行的运行时查找。 For instance, a classfile may invoke instruction System.currentTimeMillis() which is in a different classfile. 例如,一个类文件可以调用另一个类文件中的指令System.currentTimeMillis() The class ( java.lang.System ) is loaded dynamically(discussed later), and the method looked up in that class by name at runtime(though the lookup could be memoized or cached). 该类( java.lang.System )是动态加载的(稍后讨论),该方法在运行时按名称在该类中查找(尽管查找可以被记忆或缓存)。

Dynamic loading is slightly different. 动态加载略有不同。 It is the loading of code or a method when needed(ie not loading a classfile until first needed. System is not a good example as it is possibly loaded by the JVM early on though TreeMap can stand in as a good example. Dynamic binding can then occur. 它是在需要时加载代码或方法(即,直到第一次需要时才加载类文件。 System不是一个很好的例子,因为虽然TreeMap可以作为一个很好的例子,但它可能早就由JVM加载了。动态绑定可以然后发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM