• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between method signature and method prototype?

 
Ranch Hand
Posts: 133
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 133
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeff!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript has prototypes, but JavaScript is something totally different than Java.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic