Java Reference
In-Depth Information
Some casts result in an error at compile time. Some casts can be proven, at compile
time, always to be correct at run time. For example, it is always correct to convert a
value of a class type to the type of its superclass; such a cast should require no special
action at run time. Finally, some casts cannot be proven to be either always correct or
always incorrect at compile time. Such casts require a test at run time. See § 5.5 for
details.
Otherwise, at run time, the operand value is converted (if necessary) by casting conversion
to the type specified by the cast operator.
A ClassCastException is thrown if a cast is found at run time to be impermissible.
15.17. Multiplicative Operators
The operators * , / , and % are called the multiplicative operators .
MultiplicativeExpression:
UnaryExpression
MultiplicativeExpression * UnaryExpression
MultiplicativeExpression / UnaryExpression
MultiplicativeExpression % UnaryExpression
The multiplicative operators have the same precedence and are syntactically left-associat-
ive (they group left-to-right).
The type of each of the operands of a multiplicative operator must be a type that is convert-
ible (§ 5.1.8 ) to a primitive numeric type, or a compile-time error occurs.
Binary numeric promotion is performed on the operands (§ 5.6.2 ) .
Note that binary numeric promotion performs value set conversion (§ 5.1.13 ) and may
perform unboxing conversion (§ 5.1.8 ).
The type of a multiplicative expression is the promoted type of its operands.
If the promoted type is int or long , then integer arithmetic is performed.
If the promoted type is float or double , then floating-point arithmetic is performed.
15.17.1. Multiplication Operator *
The binary * operator performs multiplication, producing the product of its operands.
Multiplication is a commutative operation if the operand expressions have no side effects.
Search WWH ::




Custom Search