Home >Java >javaTutorial >What is the difference between Compact Strings and Compressed Strings in Java 9?
Compressed StringsIntroduced in Java 9 to replace Java 6’s Compressionstring. Its implementation uses byte[] arrays instead of char[] arrays, and introduces a new field encoder to identify whether it is LATIN1 or >UTF16 format, while Compression String has been introduced in Java 6, it is possible to use bytes[]each A one-byte array of characters, and continues with a char[] array of two bytes per character, which could previously be opened with -XX: UseCompressedStrings. p>
Unlike compressed strings, compressed strings do not require unpacking or repacking. Therefore, compact strings provide better performance at runtime.
CompressionString is not enabled by default in Java 6 > and needs to be set explicitly using the following command
<strong>XX:+UseCompressedStrings</strong>
Compact Strings Enabled by default in Java 9, use the following command
<strong>+XX:-CompactStrings</strong>
The above is the detailed content of What is the difference between Compact Strings and Compressed Strings in Java 9?. For more information, please follow other related articles on the PHP Chinese website!