Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm trying to understand the difference (if any) between the two.

According to the Wikipedia page for Multiple Dispatch it is synonymous with Function Overloading, but then later on goes on to say:

In a language with only single dispatch, such as Java […]

which seems like a contradiction, since Java does support function overloading.

So which is it? Is Multiple Dispatch different from Function Overloading, or is the article wrong in claiming that Java does not support Multible Dispatch?

share|improve this question
add comment

1 Answer 1

up vote 10 down vote accepted

Multiple dispatch is not (always) the same as function overloading, although they do bear some similarities. And Java does not support multiple dispatch.

In statically typed languages, including Java, the biggest difference between dispatch and overloading is that overloading is based on the static type of parameters (i.e. the choice of which method is actually called is decided compile-time), while dispatch is based on the dynamic types (i.e. the decision is made runtime). (Such languages usually don't support multiple dispatch.)

But then again, this may be a question of terminology. In dynamically typed languages, dispatch and overloading indeed seem to boil down to the same thing.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.