2 回答

TA貢獻1796條經驗 獲得超10個贊
根據Java 語言規范,您所指的稱為MethodModifier
+MethodHeader
。
從規范(§8.4 方法聲明):
MethodDeclaration:
{ MethodModifier } MethodHeader MethodBodyMethodHeader:
結果 MethodDeclarator [ Throws ]
TypeParameters { Annotation } 結果 MethodDeclarator [ Throws ]MethodDeclarator:
標識符([ FormalParameterList ])[ Dims ]

TA貢獻1831條經驗 獲得超10個贊
modifier + return type + name of method + parameters + throwing exception{
//body
}
上述語法整體稱為方法定義,您詢問的部分稱為Method-Headers。
->例如
public static int methodName(int a, int b) throws Exception
是一個叫做 Method-Header
和
public static int minFunction(int n1, int n2) {
int min;
if (n1 > n2)
min = n2;
else
min = n1;
return min;
}
這,作為一個整體稱為方法體。
添加回答
舉報