Content received from: http://JavaFAQ.nu/java-article65.html
Question: Why do not distinguish methods based on their return value? Tuesday, February 25, 2003 (00:00:00)
Posted by jalex
Q: Why Java do not distinguish methods
based on their return value?
Only on class names and arguments list?
I think, it could be obvious from declaration:
void aa(){}
int aa(){}
to use it later in a such way:
int bbb = aa();
compiler could easily distinguish which function must be used here - int, not
void...
Answer: Yes, in this situation compiler
easily will find out which kind of function must be used.
But quite often a
method can be called directly - just to do something, not to return some value.
The return value is not important here:
...
aa();
...
In this case compiler can not find out which method must be used.
And other programmer reading your program will be confused as well.
|