Java provides special processing for the String type --- provides a string pool to define a string type variable for String type: string name = "tom"; string name = new string ("Tom ") When using the first method, use a string pool, when using the second middle, it is a normal statement, if you use the first way, then when you are declaring a content is also When "Tom" string, it will use the original memory in the string pool, not to reassign the memory, that is, String Saname = "Tom" will point to the same memory
The String type is an unable to change: String type is not changed, that is, when you want to change a String object, such as name = "Madding" then virtual machine does not change the original object, but generate a new String object, then let Name point to it, if the original "Tom" does not have any object to reference it, the virtual machine's garbage collection mechanism will receive it.
Therefore, the address of String twice has changed.