Javaの「すべての値渡し」の概念と少し混乱しています。
次のコードを検討してください。
class Test {
Integer A;
String B;
...
void SetVar(Object??? var, Object value) {
// Set A variable to the value (considering that it's possible)
}
}
次のコードがおよびに設定されるSetVar
ように関数をコーディングできますか??A
2
B
Hi
void Init() {
SetVar(this.A, 2);
SetVar(this.B, "Hi");
}