Movatterモバイル変換


[0]ホーム

URL:


  1. Glossary
  2. Signature
  3. Signature (functions)

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 keywordspublic,static, orprototype).

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 calledMyObject.
  • The method is installed on theprototype ofMyObject (thus it is aninstance method) as opposed to being astatic method.
  • The name of the method ismyFunction.
  • The method accepts one parameter, which is calledvalue and 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)
  • Thepublic keyword is an access modifier and indicates that this method can be called by any object.
  • Thestatic keyword indicates that this method is a class method as opposed to being an instance method.
  • Thevoid keyword indicates that this method has no return value.
  • The name of the method ismain.
  • The method accepts one parameter of type String Array. It is namedargs.

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp