Home > Java > javaTutorial > 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
Release: 2023-09-21 14:33:07
forward
1147 people have browsed it

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>
Copy after login

Compact Strings Enabled by default in Java 9, use the following command

<strong>+XX:-CompactStrings</strong>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template