What happens if I do:
Object obj = new Object();
obj = null;
Does it remove the object from memory, or clear just the reference?
More formally, consider the code:
Object obj = new Object();
Object temp = obj;
obj = null;
Why is temp
still not null
? Shouldn't it have been removed from memory?