What is increment & decrement operator in java with example ?
Share
What is increment & decrement operator in java with example ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
Answer in easiest language is attached below.. Hope it vl help....Verified answer
Increment operator increments the value of an integer variable and float or double variable by 1.decrement reduces its value by 1. The operand must have an L value ie., an address in storage.
These operators are unary.
double x = 3.5 ; int y = 1;
x++ ; // x is now 4.5
-- x; // x is now 3.5
y ++ ; // y is now 2
--y ; // y is now 1
x++ is equivalent to (x = (x +1))
--y is equivalent to (y = (y -1))
++ and -- have higher precedence than binary operators.