Vishambar Pandey
Vishambar Pandey

Reputation: 95

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

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.

Upvotes: 4

Views: 216

Answers (2)

Robby Cornelissen
Robby Cornelissen

Reputation: 97152

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]

Upvotes: 4

Harshit Bhatt
Harshit Bhatt

Reputation: 133

  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.

.

Upvotes: 0

Related Questions