Java Reference
In-Depth Information
As a point of interest, Java also allows hexadecimal floating-point literals, but they are
seldom used.
Beginning with JDK 7, it is possible to specify an integer literal by use of binary. To do
so, precede the binary number with a 0b or 0B . For example, this specifies the value 12 in
binary: 0b1100 .
Character Escape Sequences
Enclosing character constants in single quotes works for most printing characters, but a few
characters, such as the carriage return, pose a special problem when a text editor is used.
In addition, certain other characters, such as the single and double quotes, have special
meaning in Java, so you cannot use them directly. For these reasons, Java provides special
escape sequences , sometimes referred to as backslash character constants, shown in Table
2-2 . These sequences are used in place of the characters that they represent.
Table 2-2 Character Escape Sequences
For example, this assigns ch the tab character:
The next example assigns a single quote to ch :
 
Search WWH ::




Custom Search