A_Arnold A_Arnold - 1 year ago 224
Java Question

What is Java 9's new string implementaion?

How are strings implemented in Java 9 under the hood? Is each character stored as one or two bytes?

Answer Source

Because most usages of Strings are Latin-1 and only require one byte, Java-9's String will be updated to be implemented under the hood as a byte array with an encoding flag field to note if it is a byte array. If the characters are not Latin-1 and require more than one byte it will be stored as a UTF-16 char array (2 bytes per char) and the flag. See JEP 254 and SO String Documentation: Remarks.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download