阅读以下程序,写出输出结果。
class Swap {
void sw1 (Person x, Person y){
int a = y.id;
y.id = x.id;
x.id = a;
}
void sw2 (Person x, Person y){
Person e;
e = x;
y = x;
x = e;
}
}
public class Person {
int id = 0;
Person (int id) {
this.id = id;
}
public static void main(String[] args) {
Swap cid = new Swap ();
Person p1 = new Person (10);
Person p2 = new Person (11);
Person p3 = new Person (12);
Person p4 = new Person (13);
cid.sw1(p1,p2);
cid.sw2(p3,p4);
System.out.println("p1: " + p1.id + "p2: " + p2.id);
System.out.println("p3: " + p3.id + "p4: " + p4.id);
}
}
