O'Reilly logo

The Java® Language Specification, Java SE 7 Edition, Fourth Edition by Alex Buckley, Gilad Bracha, Guy Steele, Bill Joy, James Gosling

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required