When String a = "abc"; is executed, the Java VM creates three char values 'A', 'B', and 'C' in the stack ', then create a String object in the heap. Its value is an array consisting of the three char values just created in the stack {'A', 'B ', 'C'}, and the newly created String object will be added to the String pool. If we execute String B = new String ("abc"); Code, because "abc" has been created and saved in the String pool, therefore, the Java Virtual Machine will only create a new String object in the heap, but its value (value) it shares the three char values 'A', 'B', and 'C' created in the stack during execution of the previous line of code '. String a = "abc"; an object is created in the String pool instead of in the heap. Therefore, only one object is created, and String B = new String ("abc "); there are objects in the String constant pool and heap, so they are two objects: String a = "abc"; new String ("abc") in the constant pool "); in the heap, String str1 = "abc"; the referenced object is in the stack (or the String pool. String str1 = new String ("abc"); the referenced object is in the memory/heap.