15.15. Unary Operators

The operators +, -, ++, --, ~, !, and the cast operator (§15.16) are called the unary operators.

UnaryExpression:    PreIncrementExpression    PreDecrementExpression    + UnaryExpression    - UnaryExpression    UnaryExpressionNotPlusMinusPreIncrementExpression:    ++ UnaryExpressionPreDecrementExpression:    -- UnaryExpressionUnaryExpressionNotPlusMinus:    PostfixExpression    ~ UnaryExpression    ! UnaryExpression    CastExpression

Expressions with unary operators group right-to-left, so that -~x means the same as -(~x).

15.15.1. Prefix Increment Operator ++

A unary expression preceded by a ++ operator is a prefix increment expression.

The result of the unary expression must be a variable of a type that is convertible ...

Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.