Signature (functions)
Afunction signature (ortype signature, ormethod signature) defines input and output offunctions ormethods.
A signature can include:
- parameters and theirtypes
- a return value and type
- exceptions that might be thrown or passed back
- information about the availability of the method in anobject-oriented program (such as the keywords
public,static, orprototype).
In this article
In depth
>Signatures in JavaScript
JavaScript is aloosely typed or adynamic language. That means you don't have to declare the type of a variable ahead of time. The type will get determined automatically while the program is being processed. A signature in JavaScript can still give you some information about the method:
js
MyObject.prototype.myFunction(value);- The method is installed on anobject called
MyObject. - The method is installed on the
prototypeofMyObject(thus it is aninstance method) as opposed to being astatic method. - The name of the method is
myFunction. - The method accepts one parameter, which is called
valueand is not further defined.
Signatures in Java
InJava, signatures are used to identify methods and classes at the level of the virtual machine code. You have to declare types of variables in your code in order to be able to run the Java code. Java isstrictly typed and will check any parameters at compilation time if they are correct.
java
public static void main(String[] args)- The
publickeyword is an access modifier and indicates that this method can be called by any object. - The
statickeyword indicates that this method is a class method as opposed to being an instance method. - The
voidkeyword indicates that this method has no return value. - The name of the method is
main. - The method accepts one parameter of type String Array. It is named
args.
See also
- Java internal type signatures on Wikipedia