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

 我们经常可以在源码注释中看到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 @   JustJavaIt  阅读(247)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示