String h = "hi";
here we are referencing string h to string literal hi. JVM has a string literal pool to store string literals so we can reuse the strings as they re immutable…
When we say reusable, what is the exact meaning of this? are we talking about the address ? that it is picked from same address evey time ?
Yes, to make things simpler you can think of it as picking from same address, but to be more precise variables are holding same reference which is number/objectID which JVM use while mapping to proper memory address of object (object can be moved in memory but will still have same reference).
You can test it with code like this: