Computer Science, asked by Chandransh, 1 year ago

What is increment & decrement operator in java with example ?

Answers

Answered by khanujarashmit
4
Answer in easiest language is attached below.. Hope it vl help....
Attachments:

kvnmurty: good
Chandransh: Rhabsk
Chandransh: Thanks
Answered by kvnmurty
5
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.


Chandransh: Thanks
Similar questions