Y
Hacker News
new
|
ask
|
show
|
jobs
by
leifg
3351 days ago
Am I missing something or can most of the examples just be achieved with method overloading?
1 comments
ysleepy
3351 days ago
Java only has single dynamic dispatch. That means it will use the method of the most specific sub-class, but will not dispatch on the runtime type of the argument, only its compile time type.
So something like:
for(None n: expreTree.children()) { intMath.eval(n); }
will not work as expected if eval is overloaded.
link
So something like:
will not work as expected if eval is overloaded.