属性与参数和实参有什么区别?这是如何工作的?前任:-
int a = 10;//attribute
method(int a);//argument or parameter
Run Code Online (Sandbox Code Playgroud)
如果我动态传递一个参数,那么它是否会被称为参数或参数。谢谢。
class SomeClass {
private int someAttribute; // <-- Attribute (declaration)
public void setSomeAttribute( int attrValue /* <-- Parameter (declaration) */ ) {
int twice = attrValue * 2; // (local) variable
this.someAttribute = twice;
}
public void doSomethingElse() {
int x; // (local) variable
x = 1;
setSomeAttribute(x); // the value of x is the argument
setSomeAttribute(999); // 999 is the argument
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6152 次 |
| 最近记录: |