3 ms·
I believe this was done as part of the unification of JavaSE and JavaME VMs. AFAIK saving three instance variables per String instance is a big deal on JavaME.
by needusername 12y ago
I believe this was done as part of the unification of JavaSE and JavaME VMs. AFAIK saving three instance variables per String instance is a big deal on JavaME.
ByteBuffer and CharBuffer are a way of doing array slicing. CharBuffer even implements Appendable and CharSequence so it's half way polymorphic with String.
I sometimes whish there would be multiple String classes tailored for specific purposes like there are Collection classes. Especially a String class for ASCII strings that uses only eight bytes per character.
- anon4 12y agoMy biggest gripe with String is that it's not an immutable Iterable<Char>. They could have at least implemented the interface.
- needusername 12y agoYou must be pretty happy with String then, if that's your biggest gripe :-) Do you really mean Iterable<Character> and not Iterable<Integer>. Because a Unicode code point can spawn two chars.
- TheLoneWolfling 12y agoPersonally, I wish there was a GraphemeCluster class, with a way to coerce a String into an Iterable<GraphemeCluster>, Collection<GraphemeCluster>, etc. Because most of the time people don't want to iterate over code points - they want to iterate over user-perceived characters instead. It makes more sense that by default "école".reverse() (that's the two-code-point version of "é") would be "elocé" rather than "eloće". But I've said a lot on the subject of strings already: https://news.ycombinator.com/item?id=8198811 https://news.ycombinator.com/item?id=8198811 https://news.ycombinator.com/item?id=8066158 https://news.ycombinator.com/item?id=8066158 https://news.ycombinator.com/item?id=7606084 https://news.ycombinator.com/item?id=7606084 https://news.ycombinator.com/item?id=7574665 https://news.ycombinator.com/item?id=7574665 https://news.ycombinator.com/item?id=7075858 https://news.ycombinator.com/item?id=7075858