char Data Type
The char
data type represents a single character from the Unicode character set. A character is not the same as a string.
To assign a value to a char
variable, you use a character literal, which consists of a single character enclosed in apostrophes (not quotes). Here’s an example:
char code = ‘X’;
Here, the character X
is assigned to the variable named code
.