Java Reference
In-Depth Information
There are also some characters, called escape characters, that have a special meaning. They are used
for displaying text in specific ways, either for inserting tabs or enters where desired, or by display-
ing a character that's normally reserved for code syntax. For example, we just discussed that the
single quote ( ' ) indicates the beginning and end of a char literal. But what if you want to use the ( ' )
character in your code? You can do so by putting a backslash ( \ ) before it. Some of the more com-
mon escape characters are listed in Table 2-7.
table 2-7: Escape Characters in Java
shortcut notation
meaning
unicode
Backspace
\u0008
\b
Tab
\u0009
\t
Linefeed
\u000A
\n
Carriage return
\u000D
\r
Quote mark
\u0022
\''
Apostrophe
\u0027
\'
Backslash
\u005C
\\
In order to improve code readability, you can use underscores ( _ ) anywhere within literals of a
numeric data type. Just like a space in a sentence, they break up a number into smaller parts to
make it easier to read and verify it. Consider this example:
long creditCardNumber = 1234_4567_8901L;
operators
Operators perform data manipulations on one or more input variables (called operands ). For exam-
ple, in the expression 2+3, the operands are 2 and 3, and the operator is +. In terms of the number
of operands, a distinction can be made among unary operators (one operand), binary operators (two
operands), and ternary operators (three operands). In terms of the operations performed, a distinc-
tion can be made among the following:
Arithmetic operators
Assignment operators
Bitwise operators
Logical operators
Relational operators
arithmetic Operators
Arithmetic operators perform basic mathematical operations on numerical values. The most popular
ones are listed in Table 2-8.
 
Search WWH ::




Custom Search