View RSS Feed

Java Object

Overloading on return values

Rate this Entry
by , 04-26-2012 at 06:39 PM (717 Views)
It is commonly wondered that why method argument & class names lists? Why methods shall not be distinguished ,based at return values? E.g, two methods having similar arguments and name get distinguished quite easily from each other:

void f() {}
int f() {}

It will be working fine if unequivocally a compiler finds out the meaning, as in int x = f( ). But, a method could be called and return value can be ignored; which is referred as method calling for sideeffects, since return value is not being cared , rather other method call effects are required. Therefore, method is called in this way:


How it could be determined by Java that which f() needs to be called & how someone can see the reading code? Due to such problem one cant utilize the return value types, to differentiate the overloaded methods.

Submit "Overloading on return values" to Facebook Submit "Overloading on return values" to Digg Submit "Overloading on return values" to Submit "Overloading on return values" to StumbleUpon Submit "Overloading on return values" to Google