File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Method signature Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Reply Bookmark "Method signature" Watch "Method signature" New topic
Author

Method signature

Ramesh Donnipadu
Ranch Hand

Joined: Sep 16, 2000
Posts: 100
Does return type of a method included in the method's signature?
Design Patterns by GoF says yes. But Khalid Mughal and few others say return type is not part of method's signature.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Ramesh,
It depends what you are talking about --
Technically, yes, the return type of a method is included in it's signature, since it is something that differentiates that method from other methods.

But, in Java ( and C++, and probably all other languages ) return type is usually not included in a method signature because if all that is different in two methods is the return type, Java will not know which method to call.
HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1441
As Nathan said, it depends on the context. If you are looking at it from a language perspective (C++, Java), then the answer is no. If you are talking about interfaces or object interactions then the return type is usually considered part of the signature. This assists in preventing statements like "It returns an int? I'm expecting an array of doubles!" occuring too often.
John


The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Method signature
 
Similar Threads
problem with method
Overloading
Question from examlab practice test 2
Is Return Type Included in Method Signature ?
overloading static methods?