String alpha = "Dempster Dumpster"; alpha = null; . . .
The first statement does two things:
(1) a String object is created,
containing the characters "Dempster Dumpster".
Then, (2) a reference
to that object is saved in the reference variable alpha.
The second statement assigns the value null
to alpha
.
When this happens,
the reference to the object is lost.
Since there is no reference to the object elsewhere,
it is now garbage.
The line through the box in the second statement
symbolizes the null
value.
The object still exists in memory.
The memory it consists of will eventually be
recycled by
the garbage collector
and will be made available for new objects.