Home >Java >javaTutorial >What encoding method is used for java character types?

What encoding method is used for java character types?

青灯夜游
青灯夜游Original
2019-05-16 16:35:1516110browse

What encoding method is used for java character types?

Java's character type uses the Unicode encoding scheme.

Java uses UTF-16 encoding as the internal code, which means that inside the JVM, text is represented by a 16-bit code element sequence. Commonly used texts are character (char) and string (String) literal constants. Content. However, UTF-16 is an encoding scheme of the Unicode character set.

Java characters and strings exist in the following places:

● Java source code file, *.java, can be any character encoding, such as GBK, UTF-8

● Class file, *.class, uses a modified UTF-8 encoding (Modified UTF-8)

● JVM, uses UTF-16 encoding in memory

The Java compiler needs to read the source code correctly, eliminate encoding differences, and then compile it into a UTF-8 encoded Class file. For example, javac will take the encoding of the operating system by default. You can use the parameter -encoding to specify the character encoding of the source file. The JVM loads the Class file and converts the characters or strings in it into UTF-16 encoding sequences.

The above is the detailed content of What encoding method is used for java character types?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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