Only strings created with the new keyword are placed on [normal] heap, not the string pool.
I find this to be vague. Perhaps we mean only String created using the String class and using the new keyword go on the heap.
Searching the internet has not improved my confusion.
Several things are clear (I think) -- feel free to correct me.
- Any call to new String goes on the heap.
- String literals (i.e. compile time constants) go to string pool.
- Any methods creating a new String by using methods that modify the string (like strip(), substring(), etc), will always use the String pool.
It seems to me that whether these methods use new String() could be implementation specific. new String() may or may not be invoked.
(QUESTION) How do these functions work in regard to the String pool?