Home >Java >javaTutorial >What does char mean in java
char in Java represents a primitive data type that stores a single Unicode character, using two bytes, ranging from 0x0000 to 0xFFFF, and the default value is '\u0000'. It is used to store individual characters or as part of a string.
What does char mean in Java?
char
is a primitive data type in Java used to store single Unicode characters. It uses two bytes to represent a character, allowing all Unicode code points to be stored, from 0x0000 to 0xFFFF.
Data type of char
Usage of char
The char
type is mainly used in the following situations:
'a'
, 'B'
'\u03B1'
(Greek letter α) String
) char type and String type
char
stores a single character, while String
stores a sequence of characters. char
is a primitive data type and takes up less memory, while String
is an object and takes up more memory. char
can be created by using single quotes, while String
is created by using double quotes. Example
<code class="java">char myChar = 'a'; // 存储字符'a' char greekChar = '\u03B1'; // 存储希腊字母α</code>
The above is the detailed content of What does char mean in java. For more information, please follow other related articles on the PHP Chinese website!