Jesper de Jong wrote:You expected: false, false, true
And you are getting: false, false, true
So, you are getting exactly what you expected?
I would have expected: false, true, true
Note that the intern() method puts the string into the string pool and returns a reference to the string that's in the pool. String literals are already in the pool, so s2.intern() will return the reference to the string "hi" in the pool, which is the same string as the "hi" literal that s1 refers to.
Lester Burnham wrote:How did you determine that there's a need to improve performance?
Lester Burnham wrote:Why do you think any modifications are necessary? What do you have in mind?
Campbell Ritchie wrote:Welcome to the Ranch
Lester Burnham has a good point.
Please search this forum and "Beginning Java" because several other people are asking very similar questions just now.