Meaningless Drivel is fun!*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Increment and Decrement Operators" Watch "Increment and Decrement Operators" New topic
Author

Increment and Decrement Operators

Saumya Tangeda
Greenhorn

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Increment and Decrement Operators
 
Similar Threads
Autoboxing/unboxing conundrum
bit shift
Long and float comparison
Assignments
About numeric promotion