Re:String Interning Done Right
by richardwhiuk on Saturday March 05, 2016 @05:51PM
(#11231476)
Yeah, the explanation in this article about Java's string interning made be lose confidence that the author knew what they were talking about. If you compare Strings, you should use .equals() or you are risking a logic error if you aren't very careful. Indeed, you can deliberately un-intern a string by doing new String("my string") (with little realistic value).
I don't think this is true. It looks like Java only interns string literals by default. [1] If you get a string another way (user input, for example), it's not interned unless you call the String.intern() method.
[1] https://docs.oracle.com/javase/8/docs/api/java/lang/String.h...