方法头指定修饰符(例如static)、返回值类型、方法名、和形式参数。
方法头中定义的变量称为形参 (形式参数,formal parameter 或 parameter),形参如同占位符。当方法被调用时,传递一个值给形参,此值称为实参(实际参数, actual parameter 或 argument),形参列表指的是形参的类型、顺序和形参的数目。
方法名和形参列表共同组成方法签名。
原文:
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
本文介绍了Java中方法的基本组成部分,包括方法头的构成要素如修饰符、返回值类型、方法名和形式参数等概念。详细解释了形式参数和实际参数的区别,并说明了方法签名的构成。
3181

被折叠的 条评论
为什么被折叠?



