Characters and Strings in Java

Original link: https://www.lifengdi.com/archives/course/java/3913

In Java, characters and strings are two different types. Character type The character type char is a basic data type, which is an abbreviation for character. A char holds a Unicode character: char c1 = ‘A’; char c2 = ‘中’; Because Java always uses Unicode to represent characters in memory, an English character and a Chinese character are both represented by a char type, and they are Both occupy two bytes. To display the Unicode encoding of a character, simply assign the char type directly to the int type: int n1 = ‘A’; […]

This article is reproduced from: https://www.lifengdi.com/archives/course/java/3913
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment