关于堆、栈、引用
class DataWarp{int a;
int b;
}
public class ReferenceTransferTest {
public static void swap(DataWarp dw){
int temp = dw.a;
dw.a = dw.b;
dw.b = temp;
System.out.println(dw);
System.out.println(dw.a + "," + dw.b);
dw = null;
}
public static void main(String[] args){
DataWarp dw = new DataWarp();
dw.a = 6;
dw.b = 9;
swap(dw);
System.out.println(dw.a + "," + dw.b);
System.out.println(dw);
}
}
输出结果为什么是9,6和9,6,而不是9,6和6,9?