Home  >  Article  >  Java  >  What is the difference between Compact Strings and Compressed Strings in Java 9?

What is the difference between Compact Strings and Compressed Strings in Java 9?

WBOY
WBOYforward
2023-09-21 14:33:071075browse

Java 9中Compact Strings和Compressed Strings之间的区别是什么?

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete