Parameters are the variables that are listed as part of a method declaration. Each parameter must have a unique name and a defined data type.
参数是作为方法声明的一部分列出的变量。 每个参数必须具有唯一的名称和定义的数据类型。
参数示例 ( Parameter Example )
Within a method to compute a change to a Circle object's position, the method changeCircle accepts three parameters: a name of a Circle object, an integer representing a change to the X-axis of the object and an integer representing a change to the Y axis of the object.
在用于计算Circle对象位置变化的方法中, changeCircle方法接受三个参数:Circle对象的名称,代表对象X轴变化的整数和代表Y轴变化的整数对象。
public void changeCircle(Circle c1, int chgX, int chgY) {
c1.setX(circle.getX() + chgX);
c1.setY(circle.getY() + chgY);
}
When the method is called using example values (e.g., changeCircle(Circ1, 20, 25)), the program will move the Circ1 object up 20 units and right 25 units.
当使用示例值(例如changeCircle(Circ1,20,25) )调用该方法时, 程序会将Circ1对象向上移动20个单位,向右移动25个单位。
关于参数 ( About Parameters )
A parameter may be of any declared data type -- either primitives like integers, or reference objects including arrays. If a parameter may become an array of an indeterminant number of data points, create a vararg by following the parameter type with three periods (an ellipsis) and then specifying the parameter name.
参数可以是任何已声明的数据类型-整数之类的原语,或包括数组的引用对象。 如果参数可以成为数据点的超静定数目的阵列,通过以下三个周期(省略号),然后指定参数名称的参数类型创建一个可变参数 。