I read this Questions about Java's String pool and understand the basic concept of string pool but still don\'t understand the behavior.
First: it works if you
See the documentation for String#intern(). The last line there states:
All literal strings and string-valued constant expressions are interned.
Your += example is neither a literal string nor a string-valued constant expression, so it is not put in the String pool.
+=