Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Increment and Decrement Operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Increment and Decrement Operators" Watch "Increment and Decrement Operators" New topic

Increment and Decrement Operators

Saumya Tangeda

Joined: Jul 09, 2006
Posts: 24
I read about the rules for unary and binary numeric promotion.
Unary numeric promotion is valid for operators:+,-,~,[],<<,>>>,>>
Binary numeric promotion is valid for: -relational operators
-bitwise operators
- == and !=
-arithmetic operators
Does the type promotion occur for ++ and - - operators?What type?Unary or Binary?
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Yes, it happens. Promotion and autocasting.

For instance:

This is equal to:

The ++ and -- operators act on a single operand, therefore the answer to your questions regarding if this is a binary or unary numeric promotion is evident.
I agree. Here's the link:
subject: Increment and Decrement Operators
It's not a secret anymore!