File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic dispatch??????

 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is Dynamic Dispatch in Java?
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you understand what dynamic dispatch is and just want to know how to implement it in Java, or do you want to know what dynamic dispatch is ?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google is your friend. Search for "Dynamic Dispatch". I tried to paste the resulting URL in here but it turned into emoticons instead of a url.

The WikiPedia is pretty amazing, but their article on dynamic dispatch doesn't have Java!
[ October 03, 2005: Message edited by: Stan James ]
 
Naveen Vooka
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.objectfaq.com/oofaq2/DynamicDispatch.htm
http://www.objectfaq.com/oofaq2/DynInh.htm

--------------
Naveen Vooka
www.devsquare.com
DevSquare - Online Application Development
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think those links are trying to sell you something ... a framework that makes Java simulate multiple inheritance. They rendered so poorly on Firefox that I didn't try very hard to figure it out.

Dynamic dispatch is the fundamental language feature that enables runtime polymorphism. When I code a method call on a variable declared as an interface there is no code present at compile time to be called. At runtime the JVM routes the call to the actual class of the object referenced by the variable.

List books = getBooks();
System.out.println(books.size());

List promises that a method size() exists but doesn't implement it. Some concrete class like LinkedList implements it and the JVM does "dynamic dispatch" to the concrete method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic