Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Increment decrement operators  RSS feed

 
syed quadri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I was trying to run following code & got the out put as 1 2 3 3..but I need some clarification as to the out put of Line 4 operation a=a++.. that prints 3.

Can someone explain why it is not printing 4 ? I understand the difference between pre and post increment.. and I think increment happens on line 4 but not sure why it is printing 3..


 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
syed quadri wrote:Hello,

I was trying to run following code & got the out put as 1 2 3 3..but I need some clarification as to the out put of Line 4 operation a=a++.. that prints 3.

Can someone explain why it is not printing 4 ? I understand the difference between pre and post increment.. and I think increment happens on line 4 but not sure why it is printing 3..




See... https://www.coderanch.com/how-to/java/PostIncrementOperatorAndAssignment

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!