简体   繁体   中英

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.

Dynamic binding is a runtime lookup by name. For instance, a classfile may invoke instruction System.currentTimeMillis() which is in a different classfile. 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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