Letter 是一个创建好的类。
class Letter {
char c;
}
public class PassObject {
static void f(Letter y) {
y.c = 'z';
}
}
public static void main(String[] args){
Letter x = new Letter ();
x.c = 'a' ;
print("1:x.c: " + x.c );
f(x);
print("2:x.c: " + x.c);
}
}
上面这个代码中方法 f(Letter y) 里的 Letter y是什么意思?
main方法里的f(x);参数是对象x又是什么样的原理?