3 ms·
This is actually what Java does when you call substr, effectively (String objects contain a reference to a char array, a length, and an offset).
by ZoFreX 15y ago
This is actually what Java does when you call substr, effectively (String objects contain a reference to a char array, a length, and an offset).
- daemin 15y agoThat's also because (to my knowledge) that strings in Java are immutable. Same as in Ruby and a bunch of other languages. So the optimisation that can be done is to put all of the string data into one big (immutable) array and have each string object just reference into it for its data.