File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading and Method Signatures

 
Jay Damon
Ranch Hand
Posts: 282
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The statement is incorrect. For the purposes of overloading, only the argument types matter.
 
Francis Siu
Ranch Hand
Posts: 867
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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."
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic