English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

what is this method signature? and what are its uses in programming? what is its role in overriding and overloading?

2007-03-06 15:59:43 · 3 answers · asked by Database 2 in Computers & Internet Programming & Design

3 answers

The term "method signature" has an exact meaning in Java and is explicitly defined in the Java Language Specification.

The signature of a method consists of the method name and the parameter list (type and number). It DOES NOT include the return type or modifiers such as access modifiers (public, protected, , private), abstract, static, etc.

For example, you cannot have two methods with the same name and parameter list that differs only in that one is static and the other is not, or that differ in that one returns void and the other returns a non-void value.

The use of generics resulted in the addition of the term subsignature, which is documented in the latest Java Language Specification.

2007-03-08 04:24:42 · answer #1 · answered by vincentgl 5 · 1 0

The signature is just that...A signature.

public void getCalc()
public void getCalc(double a)

These may look the same, however, they aren't. They each have a different signature. The first has no parameters and the second has a double being passed into it.

The purpose is that it makes your program flexible for user interfaces and such.

2007-03-06 16:06:34 · answer #2 · answered by Mantis 2 · 0 1

Signature in of method is the prototype of that method.
for example.
public static void main(String args[])

the signature of the above main method is
it has the String array as the parameter. It returns nothing and it is the public static method. Just like that.

2007-03-06 16:15:29 · answer #3 · answered by Anonymous · 0 1

fedest.com, questions and answers