• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unary Operators  RSS feed

 
jnrohit Jain
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this example line #5 assigns value of a (i.e. 1) to c first and then perform unary operator ++ and save new value in variable a. At line #10 it assigns value of "a" (i.e. 1) to variable "a" first and after that I hope it will perform unary operator ++ but I do not understand where that new value get stored if not in variable "a".




Result:
value of c: 1
value of a: 2
value of a: 1
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The new value is not stored anywhere.

This line a = a++ has the same effect as:
Please read this: https://coderanch.com/wiki/659942/Post-Increment-Operator-Assignment
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!