public class Test
{
public static void swap(UserName A,UserName B)
{
UserName temp = A;
A = B;
B = temp;
}
public static void main(String args[])
{
//Test t = new Test();
UserName userA = new UserName("A");
UserName userB = new UserName("B");
swap(userA,userB);
System.out.println(userA.getName());
System.out.println(userB.getName());
}
}
class UserName
{
String name = "";
public UserName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
以上这段代码得运行结果,没发生交换,谁能说下它得运行过程。。。