Dynamic binding == late binding in Java or not?

2019-04-27 18:16发布

In different sources i've read different things on the topic. For example Wikipedia says:

Late binding is often confused with dynamic dispatch, but there are significant differences.

But a couple lines later

it is popular to use the term late binding in Java programming as a synonym for dynamic dispatch. Specifically, this refers to Java's single dispatch mechanism used with virtual methods.

So where's the truth and what are this "significant differences"?

1条回答
狗以群分
2楼-- · 2019-04-27 19:07

Late binding and dynamic single dispatch are, for all intents and purposes, the same. In dynamic single dispatch, the value or identity of a single object determines which code is invoked at runtime, and that's what happens in Java.

The term dynamic dispatch in general is most often used to imply dynamic multiple dispatch, which is where the runtime method is chosen at runtime based on the identities or values of more than one object, which is a language feature in CLOS and Smalltalk, but not in Java or C++.

查看更多
登录 后发表回答