Java Reference
In-Depth Information
value of the expression is returned. If the operator comes after (post-
fix), the operation is applied after the original value is used. For ex-
ample:
class IncOrder {
public static void main(String[] args) {
int i = 16;
System.out.println(++i + " " + i++ + " " + i);
}
}
The output is
17 17 18
The expression
++i
preincrements the value of
i
to 17 and evaluates to
that value (17); the expression
i++
evaluates to the current value of
i
(17) and postincrements
i
to have the value 18; finally the expression
i
is the value of
i
after the postincrement from the middle term. Modi-
fying a variable more than once in an expression makes code hard to
understand, and should be avoided.
The increment and decrement operators
++
and
--
can also be applied to
char
variables to get to the next or previous Unicode character.
9.2.2. Relational and Equality Operators
The language provides a standard set of relational and equality operat-
ors, all of which yield
boolean
values:
greater than
>