0% found this document useful (0 votes)
6 views

Unary Operators in Java

Uploaded by

Sumedh Chaware
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Unary Operators in Java

Uploaded by

Sumedh Chaware
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Increment Operators are used to increased the value of the variable by one and Decrement Operators

are used to decrease the value of the variable by one in Java.

Both increment and decrement operator are used on a single operand or variable, so it is called as a
unary operator.

Unary operators are having higher priority than the other operators it means unary operators are
executed before other operators.

Note: Increment and decrement operators are can not apply on constant.

Type of Increment Operator


• Pre-increment
• Post-increment

=> pre-increment (++ variable):


In pre-increment first increment the value of variable and then used inside the expression (initialize
into another variable).

=> post-increment (variable ++):


In post-increment first value of variable is used in the expression (initialize into another variable) and
then increment the value of variable.

Type of Decrement Operator


• Pre-decrement
• Post-decrement

=> pre-decrement (-- variable):


In pre-decrement first decrement the value of variable and then used inside the expression (initialize
into another variable).

=> post-decrement (variable --):


In Post-decrement first value of variable is used in the expression (initialize into another variable) and
then decrement the value of variable.

You might also like