源码注释中的"方法签名"是什么意思?

 我们经常可以在源码注释中看到method signature,也就是方法签名,那它指的是方法中的哪部分呢?

好比@Async中的第二段注释中

 《Java语言程序设计》一书中对方法的描述中有提到,原文如下:

  The method header specifies the modifiers, return value type, method name, and parameters of the method. The static modifier is used for all the methods in this chapter. The reason for using it will be discussed in Chapter 8, Objects and Classes.

  The variables defined in the method header are known as formal parameters or simply parameters. A parameter is like a placeholder: when a method is invoked, you pass a value to the parameter. This value is referred to as an actual parameter or argument. The parameter list refers to the method’s type, order, and number of the parameters. The method name and the parameter list together constitute the method signature. Parameters are optional; that is, a method may contain no parameters. For example, the Math.random() method has no parameters

[1] Introduction to Java Programming 10th. 6.2 Defining a Method

  方法头指定修饰符、返回值类型、方法名和方法参数。静态修饰符用于本章中的所有方法。使用它的原因将在第8章“对象和类”中讨论。

  在方法头中定义的变量称为形式参数或简单的参数。参数类似于占位符:在调用方法时,将值传递给参数。这个值被称为实际的形参或实参。参数列表是指方法的参数的类型、顺序和数量。方法名和参数列表一起构成方法签名。参数为可选参数;也就是说,方法可以不包含参数。例如,Math.random()方法没有参数。

posted @ 2022-12-02 14:12  JustJavaIt  阅读(155)  评论(0编辑  收藏  举报