Non-strict floating-point execution allows intermediate results within expressions to take on values with a
greater range than allowed by the usual float or double representations. These extended range
representations avoid some underflows and overflows that can happen with the standard representations.
Fields, array elements, local variables, parameters, and return values always use the standard representations.
When an extended range representation is converted to a standard representation, the closest representable
value is used.
If you need a complete understanding of these issues, you should consult The Java™ Language Specification,
Third Edition.
9.2. General Operators
In addition to the main arithmetic operators, there are other useful operators for comparing and manipulating
values. Member access operators, method invocation and type conversion operators are discussed in following
sections.
9.2.1. Increment and Decrement Operators
The ++ and -- operators are the increment and decrement operators, respectively, and can only be applied to
numeric variables or numeric array elements. The expression i++ is equivalent to i=i+ 1 except that i is
evaluated only once. For example, the statement
++arr[where()];
invokes where only once and uses the result as an index into the array only once. On the other hand, in the
statement
arr[where()] = arr[where()] + 1;
the where method is called twice: once to determine the index on the right-hand side, and a second time to
determine the index on the left-hand side. If where returns a different value each time it is invoked, the
results will be quite different from those of the ++ expression. To avoid the second invocation of where you
would have to store its result in a temporaryhence the increment (and decrement) operator allows a simpler,
succinct expression of what you want to do.
The increment and decrement operators can be either prefix or postfix operatorsthey can appear either before
or after what they operate on. If the operator comes before (prefix), the operation is applied before the value
of the expression is returned. If the operator comes after (postfix), the operation is applied after the original
value is used. For example:
class IncOrder {
public static void main(String[] args) {
int i = 16;
System.out.println(++i + " " + i++ + " " + i);
}
}