I have this piece of code, and I would like to know why the reference of my variable x is not modified ? It still points to the first object assigned:
public class HelloWorld{
public static void main(String []args){
Object x = new Object();
Object y = x;
mutate(x);
System.out.println(Integer.toHexString(x.hashCode()));
System.out.println(Integer.toHexString(y.hashCode()));
System.out.println(x == x); // true
System.out.println(x == y); // true
}
public static void mutate(Object x) {
x = new String();
}
}