4 ms·
String is one that has changed pretty significantly - count and offset have been removed, only fields are hash and value now. This means String.substring is no
by jcdavis 10y ago
String is one that has changed pretty significantly - count and offset have been removed, only fields are hash and value now.
This means String.substring is no longer an O(1) method, but it saves 8 bytes per string which is huge, and also avoids some of the wierd corner case GC/memory issues that substring/StringBuilder caused by hanging on to the reference
- geodel 10y agoRight. Java 9 will move from char[] to byte[] for String.value which will lead to further savings.