Character Data Type
A char
can store a single 16-bit Unicode character. A character literal is enclosed in single quotes.
- Occupies
2
bytes. - The default value is
0
. - It can store a minimum value of
\u0000
(0
in the decimal representation, also called thenull
character) and the maximum of\uffff
or(2^16 - 1)
. - The char values are
A
,B
,a
,d
, etc.
public class CharType {
public static void main(String[] args) {
char myChar = 'u'; // 'u'
char myChar2 = '5'; // '5'
char myChar3 = 65; // 'A'
}
}