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?
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.
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.
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
posted
0
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
posted
0
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: 32689
4
posted
0
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: 32689
4
posted
0
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.