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
.
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.