|
|
|
|
|
by fweimer
1133 days ago
|
|
That's fairly underwhelming? I don't think it's correct for any version of the JVM. Really old versions had offset/length fields, but never a length field on its own. (Back then, substring() didn't make full copies.) For mainline Java, since version 9, strings can use a byte[] to store characters if the string consists entirely of characters in the Latin-1 subset. String literal assignment does not allocate, and concatenation allocates a new String object and internal array. What is being described is closer to a typical implementation of C++ std::string, without the small-strings optimization. And it's written rather convincingly. |
|