While we're at it, a further erratum: the negative unary operator also does not imply a number is necessarily negative. It just causes the sign to change - either positive to negative, or negative to positive. And it's also promoted to int, unless it's already long, float, or double.
Jeanne Boyarsky wrote:Scott and I chatted. We are ok with our simplified book explanation.
Why do you think that the description in the book is a simplified version? I am asking as I may be missing something. The JLS (15.15.3), states
15.15.3. Unary Plus Operator + The type of the operand expression of the unary + operator must be a type that is convertible (§5.1.8) to a primitive numeric type, or a compile-time error occurs.
Unary numeric promotion (§5.6) is performed on the operand. The type of the unary plus expression is the promoted type of the operand. The result of the unary plus expression is not a variable, but a value, even if the result of the operand expression is a variable.
At run time, the value of the unary plus expression is the promoted value of the operand.
I would mention this fact in the book for completeness, even if it is not in scope for the exam.
Why do you think that the description in the book is a simplified version? I am asking as I may be missing something. ... I would mention this fact in the book for completeness, even if it is not in scope for the exam.
I think the average reader would find it simpler. (Not every reader, you didn't.) We definitely aren't including things for completeness. This book is to help pass the exam. It's not the Java Language Specification.