How are strings implemented in Java 9 under the hood? Is each character stored as one or two bytes?
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.