What is the name for the part of a method which is not part of the signature or body

时间:2018-07-25 04:50:40

标签: java methods signature

As we know in java, the method signature contains only method name and its parameters. It doesn't include modifiers and return type and not also exception that this method is throwing. Up to this its okay.

So my doubt is if:

Name of method + parameters --> known as **method signature**

then

modifier + return type + name of method + parameters + throwing exception --> known as ????

I hope I made you guys understood of my question.

2 个答案:

答案 0 :(得分:4)

According to the Java Language Specification, what you are referring to is called the
MethodModifier + MethodHeader.

From the specification (§8.4 Method Declarations):

MethodDeclaration:
    {MethodModifier} MethodHeader MethodBody

MethodHeader:
    Result MethodDeclarator [Throws]
    TypeParameters {Annotation} Result MethodDeclarator [Throws]

MethodDeclarator:
    Identifier ( [FormalParameterList] ) [Dims]

答案 1 :(得分:0)

  modifier + return type + name of method + parameters + throwing exception{
   //body
   }

The above syntax as whole is called the method definition and the part you have asked about is called Method-Headers .

->For example

  public static int methodName(int a, int b) throws Exception

is a called Method-Header

And

     public static int minFunction(int n1, int n2) {
       int min;
       if (n1 > n2)
          min = n2;
            else
         min = n1;

        return min; 
     }

This,as whole is called Method Body.

.