5.6. Numeric Promotions
Numeric promotion is applied to the operands of an arithmetic operator.
Numeric promotion contexts allow the use of:
• an identity conversion (§5.1.1)
• a widening primitive conversion (§5.1.2)
• an unboxing conversion (§5.1.8)
Numeric promotions are used to convert the operands of a numeric operator to a common type so that an operation can be performed. The two kinds of numeric promotion are unary numeric promotion (§5.6.1) and binary numeric promotion (§5.6.2).
5.6.1. Unary Numeric Promotion
Some operators apply unary numeric promotion to a single operand, which must produce a value of a numeric type:
• If the operand is of compile-time type Byte
, Short
, Character
, or Integer
, it is subjected to unboxing conversion ...
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.