first, a minor point. there is no string class - it's the String class.
You may want to search for something called the "string pool". In Java, literal strings are created in the string pool. No matter how many times you see "Hi" in the code, there is one special string literal in the pool for that value.
each time you see the
word "new" in the code, a new object is being created.
so, if you use String s = new String("Hi");, you put the string "Hi" in the string pool, and use THAT string to create a new String object.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors