Java Reference
In-Depth Information
or as
In the foregoing example, there is no difference whether the increment is applied as a
prefix or a postfix. However, when an increment or decrement is used as part of a larger
expression, there is an important difference. When an increment or decrement operator pre-
cedes its operand, Java will perform the corresponding operation prior to obtaining the op-
erand's value for use by the rest of the expression. If the operator follows its operand, Java
will obtain the operand's value before incrementing or decrementing it. Consider the fol-
lowing:
In this case, y will be set to 11. However, if the code is written as
then y will be set to 10. In both cases, x is still set to 11; the difference is when it happens.
There are significant advantages in being able to control when the increment or decrement
operation takes place.
Relational and Logical Operators
In the terms relational operator and logical operator, relational refers to the relationships
that values can have with one another, and logical refers to the ways in which true and
false values can be connected together. Since the relational operators produce true or false
results, they often work with the logical operators. For this reason they will be discussed
together here.
The relational operators are shown here:
Operator
Meaning
= =
Equal to
!=
Not equal to
>
Greater than
<
Less than
Search WWH ::




Custom Search