The string type is a commonly used type in the actual work, separated from the data type, string is a reference type and is a class defined in the API. So objects of type string can be created using new, such as String Name=new string ("string"), assigning the variable name to a value of "string", but string analogy other classes are somewhat special, can use ' = ' to directly assign values, such as String Name= "string", which is also assigned to the variable name, a value of "string", the two assignments are different, using new assignment, always creates a new object, initializes the value of the string in the new memory space, and uses "=" To assign the value, Instead of initializing a new string each time, it looks for a string from a "string instance pool" with no strings to be assigned, assuming that there is a direct reference, and if not, initializes a string and puts it into the string instance pool. In practical programming, "=" is often used to assign a value to a variable of type string.
The Java Foundation review for string objects, can use "=" assignment, can also use Newkeyword assignment, what is the difference between the two ways?