|
|
|
1000 Java Tips ebook
|
|
 

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java
programming articles and tips. Please take your copy here.
Take your copy of free "Java Technology Screensaver"!. |
|
Question: Why do not distinguish methods based on their return value?
|
JavaFAQ Home » Daily Tips

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.
Printer Friendly Page
Send to a Friend
..
Search here again if you need more info!
|
|
|