I know that Strings are stored on the heap and the reference to them is stored on the stack. So in the code below one
would point to "John"
on the heap from the stack and likewise two
would point to "Smith"
on the heap from the stack.
So what happens when i do one = two
?
Does one
now point to where two
points to because two
contains a reference to a point on the heap or does it change the "John"
on the heap to "Smith"
?
String one;
one = "John";
String two = "Smith"
one = two;