Reputation: 77
In Java, is a++
a postfix operator or an unary operator? In the Operator Precedence from Oracle, it is separated. Reference
Upvotes: 0
Views: 277
Reputation: 106
It’s both. It’s a unary operator because it works solely on one term. If it’s x++ then it’s a postfix operator as it’s incremented after using the variable’s value. A prefix unary operator is ++x where it’s incremented before being used. Prefix operators have a higher precedence, but they’re both unary operators
Upvotes: 4