
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Differences Between Compact Strings and Compressed Strings in Java 9
Compact Strings have introduced in Java 9 to replace Java 6's Compressed Strings. Its implementation uses byte[] array instead of char[] array and a new field coder has introduced to identify whether it is LATIN1 or UTF16 format while Compressed Strings have introduced in Java 6 that can be used byte[] array for one byte per character, and continued to use char[] array for two bytes per character, previously it can be turned on using -XX: + UseCompressedStrings.
Unlike Compressed Strings, Compact Strings do not require un-packing or re-packing. Hence Compact String gives better performance at runtime.
Compressed Strings are not enabled by default in Java 6, and need to be set explicitly using below command
XX:+UseCompressedStrings
Compact Strings are enabled by default in Java 9 by using the below command
+XX:-CompactStrings