File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Overloading and Method Signatures Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Overloading and Method Signatures" Watch "Overloading and Method Signatures" New topic
Author

Overloading and Method Signatures

Jay Damon
Ranch Hand

Joined: Jul 31, 2001
Posts: 282
I subscribe to the Java Technology Fundamentals newsletter. In the 7/7/2003 newsletter, it says:
"Overloading is the ability to have a class with multiple methods of the same name where the arguments and return type (method signature) allow the compiler to determine which of the same named methods were meant to be called."
I always thought that a method signature did NOT include the return type. Indeed, if I try to enter two methods with the same name, same arguments, and different return types using my IDE (WSAD 5), it is flagged as an error (Duplicate method name).
I've always thought it would be useful to specify methods whose only difference is in the return type. Is this statement incorrect or is it possible to create methods whose only difference is the return type?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

The statement is incorrect. For the purposes of overloading, only the argument types matter.


[Jess in Action][AskingGoodQuestions]
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
Yes, Method Signature is including the method name and parameter list,but it is NOT including the return type.
So the following statement is false
"Overloading is the ability to have a class with multiple methods of the same name where the arguments and return type (method signature) allow the compiler to determine which of the same named methods were meant to be called."


Francis Siu
SCJP, MCDBA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overloading and Method Signatures