code:If x were a reference, then that would work. Notice that this shows a difference between pointers and references other than nullability. However, in java non-primitive variables are called references, despite generally behaving like pointers that have been passed by value (everything in java is pass by value).public void doStuff(Object x) {
x = new Object();
}
public static void main(String[] args) {
Object y = new Object();
z = y;
doStuff(y);
assert y != z;
}