News for hackers. Stuff that matters.
Re:String Interning Done Right by wtetzner on Saturday March 05, 2016 @04:50PM (#11231244)
>You can see why Java needs these types. With permanent default interning, any sort of sequence involving character-level appends, such as reading the contents of a book from a file, would result in a preposterous O(n²) version of an otherwise trivial technique.

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...

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).