请考虑以下代码:
public class Office {
int room;
Office(int room) {
this.room = room;
}
}
class Test {
public static void F2(Office o1, Office o2) {
o2 = o1;
o2.room = 63;
}
public static void main(String[] args) {
Office labOffice = new Office(130);
Office commonOffice = new Office(275);
F2(labOffice, commonOffice);
System.out.println(labOffice.room + ", " + commonOffice.room);
}
}
在方法F2
内,将o2.room
设置为63后,o1.room
和o2.room
不应该变为63吗?为什么打印仍然为commonOffice
提供275?