char tab = '\t' , nul = '\ 000 ' , aleph = '\u05D0' , slash = '\\' ;
Table 2-2 lists the escape characters that can be used in char literals. These charac‐
ters can also be used in string literals, which are covered in the next section.
Table 2-2. Java escape characters
The Latin-1 character with the encoding xxx , where xxx is an octal (base 8) number
between 000 and 377. The forms \ x and \ xx are also legal, as in \0 , but are not
recommended because they can cause diiculties in string constants where the escape
sequence is followed by a regular digit. This form is generally discouraged in favor of the
The Unicode character with encoding xxxx , where xxxx is four hexadecimal digits.
Unicode escapes can appear anywhere in a Java program, not only in character and string
char values can be converted to and from the various integral types, and the char
data type is a 16-bit integral type. Unlike byte , short , int , and long , however, char
is an unsigned type. The Character class defines a number of useful static
methods for working with characters, including isDigit() , isJavaLetter() , isLo
werCase() , and toUpperCase() .
The Java language and its char type were designed with Unicode in mind. The
Unicode standard is evolving, however, and each new version of Java adopts a new
version of Unicode. Java 7 uses Unicode 6.0 and Java 8 uses Unicode 6.2.
Recent releases of Unicode include characters whose encodings, or codepoints , do
not fit in 16 bits. These supplementary characters, which are mostly infrequently