Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between method signature and method prototype?

 
rohit chavan
Ranch Hand
Posts: 132
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 132
Hibernate Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeff!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15632
46
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript has prototypes, but JavaScript is something totally different than Java.
 
Slaxmi Raj
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51394
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51394
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic