This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Difference between method signature and method prototype? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between method signature and method prototype?" Watch "Difference between method signature and method prototype?" New topic
Author

Difference between method signature and method prototype?

rohit chavan
Ranch Hand

Joined: Oct 08, 2010
Posts: 131

Hi all!

I want to know the difference between method signature and method prototype.
Technically, in Java, a method signature consists only of the name of the method and the parameter types and their order.
The modifiers, return type and throws clause are not part of the signature.
Is it the signature and return type or is the signature, return type and all modifiers?



Thanks!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

rohit chavan wrote:Hi all!

I want to know the difference between method signature and method prototype.
Technically, in Java, a method signature consists only of the name of the method and the parameter types and their order.


Correct. And there's no such thing as a method prototype in Java.
rohit chavan
Ranch Hand

Joined: Oct 08, 2010
Posts: 131

Thanks Jeff!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

You're welcome.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

JavaScript has prototypes, but JavaScript is something totally different than Java.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Slaxmi Raj
Ranch Hand

Joined: Apr 20, 2012
Posts: 40
A method signature consists only of the name of the method and the parameter types and their order. The modifiers, return type and throws clause are not part of the signature
Function prototypes are a C concept that is not relevant to Java.
A function prototype is basically a definition for a function. It is structured in the same way that a normal function is structured, except instead of containing code, the prototype ends in a semicolon.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Slaxmi Raj wrote:A method signature consists only of the name of the method and the parameter types and their order. The modifiers, return type and throws clause are not part of the signature


As already pointed out.

Function prototypes are a C concept that is not relevant to Java.


Also already pointed out.

A function prototype is basically...


Not relevant.
Ole Borch
Greenhorn

Joined: Sep 13, 2012
Posts: 2
Jeff Verdegan wrote:
rohit chavan wrote:Hi all!

I want to know the difference between method signature and method prototype.
Technically, in Java, a method signature consists only of the name of the method and the parameter types and their order.


Correct. And there's no such thing as a method prototype in Java.


In C we know about prototypes and the same i Java Interface we have a similar thing.
Ole Borch
Greenhorn

Joined: Sep 13, 2012
Posts: 2
Slaxmi Raj wrote:A method signature consists only of the name of the method and the parameter types and their order. The modifiers, return type and throws clause are not part of the signature
Function prototypes are a C concept that is not relevant to Java.
A function prototype is basically a definition for a function. It is structured in the same way that a normal function is structured, except instead of containing code, the prototype ends in a semicolon.


Whom /where is signature defined? For me I need a word for function - lets call it 'footprint' for now (everything before {}) since this footprint is copied into extracted interface (apart from abstract) followed by a ;, which I call prototype. Footprint followed by {} I call implementation.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37874
    
  22
Ole Borch wrote: . . . In C we know about prototypes and the same i Java Interface we have a similar thing.
I am afraid you are mistaken. Function prototypes in C and interfaces in Java are different from each other.

And welcome to the Ranch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37874
    
  22
Ole Borch wrote: . . . this footprint is copied into extracted interface (apart from abstract) followed by a ;, which I call prototype. . . .
I am afraid that is incorrect. The method header is copied from the interface into the implementing classes. The term footprint is not a usual Java term and should not be used. Nor prototype. The [abstract] method in the interface is copied exactly into the implementing classes, the public access being implicit. The return type and modifiers are part of the method heading, but not part of the signature.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between method signature and method prototype?
 
Similar Threads
Overridden doubt
Is Return Type Included in Method Signature ?
Overloading Signature
Overriding static functions
example of dynamic binding