public static void main(String[] arg) {
bb obj = new bb();
call(obj);
System.out.println("obj:" + obj.getCc()); }
public static void call(bb t) {
bb t2 = new bb();
t2.setCc("123");
t.setCc("321");
t = t2;
}
输出的值为obj:321;
public static void main(String[] arg) {
bb obj = new bb();
call(obj);
System.out.println("obj:" + obj.getCc()); }
public static void call(bb t) {
bb t2 = new bb();
t2.setCc("123");
t = t2;
t.setCc("321");
}
输出的值为obj:null;
由此可见 java传递的是引用的拷贝,而不是引用的本身