One.
For a parse of the string memory.
Now introduce a method, for a while to use, but the actual development is not uncommon.
Intern () can operate on a constant pool,
S1 is an object, and then uses the S1 object to invoke the method in the operation constant pool, calling this method to return the object in the pool.
And then the comparison, S1==s2? The result is false, and it is one thing to follow the same notation.
Here the S1 is an object in the heap, I object to the pool to find, not in the pool, and then in the pool built a return to the.
You can get it back in the pool without creating a return.
(Eclipse look at the source, put the cursor on the string, click F3 to switch directly to string.class this source file.) Holding down CTRL, using the mouse against the string, there are two options, one is explanation, the other is implementation. Click to explain)
For string S1=new string ("abc"); Here new is two objects, and the "ABC" string object is maintained in the object in heap memory. The S1.intern is to get the data in the pool. The data in the pool is the shared data.
Java-preliminary Understanding-Common Object API (string class-Common functionality-intern method)