If I create a
String and change it several times, like this:
The value of name ends up being Steve. But since Strings are immutable, the way I understand it is that I've actually created four Strings and I've only changed the reference that the
name instance points to.
So, if I have a more complicated program that may modify strings thousands of times, is it actually leaving all of those separate strings in memory, or does the garbage collector clean them up when nothing references them?