一、求下面程序的运行结果:
public class PrintTest {
public static void main(String[] args){
User origin = new User(“userA”);
User dest = new User(“userB”);
swap(origin,dest);
System.out.println(origin.getUserName());
}
public static void swap(User userA, User userB){
User tmp = userA;
userA = userB;
userB=tmp;
}
static private class User{
String userName = null;
User(String name){
userName = name;
}
String getUserName (){
return userName;
}
}
}
二、 当overwrite了一个Object的equals方法,一般还要overwrite什么方法,为什么?