Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: