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 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.