2 ms·
> If you assign a primitive type's value to another variable, the value is copied - not assigned a reference to the first variable (which is what happens for ob
by aliceryhl 4y ago
> If you assign a primitive type's value to another variable, the value is copied - not assigned a reference to the first variable (which is what happens for objects).
Assigning an object also just copies the value - i.e. the reference to the heap value. So the new variable does not end up pointing to the first variable. Rather, both variables end up pointing to the same heap value.