2 ms·
Okay I understand. In Java, the default String class has the option to "intern" a string which just maintains a list of strings that can be shared. The change
by foo_barrio 6y ago
Okay I understand. In Java, the default String class has the option to "intern" a string which just maintains a list of strings that can be shared.
The change was made because often the devs were unaware of the string manipulation taking place in a third party library (eg XML/JSON/HTML parsing). You'd see the memory balloon, investigate and notice that String/char[] instances were dominating your heap. Instead of changing the entire implementation of the standard String class, they changed the semantics of the "substring()" call from O(1) to O(n) + memory side-effects.