File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with increment operator.

 
viki Bhardwaj
Ranch Hand
Posts: 74
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Guys,

here i have a question regarding increment operator , code is bellow


in the above code i'm trying to increment the value of x , at the first sop(x) is good ,but at x=x++ here is also ok because here is the post increment so it first assign the value and then increment ..here my
doubt is that...
when i print through sop(x) then it again print 11 as output but what happened with corresponding post incremented value of x which should be 12 logically..but sopln() is unable to get it why???
so please i would like to know about this ....how ??

hopefully, waiting for your reply.

regards:
vivek
 
Winston Gutkowski
Bartender
Pie
Posts: 9484
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek Bhardwaj wrote:when i print through sop(x) then it again print 11 as output but what happened with corresponding post incremented value of x which should be 12 logically..but sopln() is unable to get it why???

It got lost. You need to go back to:
x = x++;
What do you think that does?

Winston
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We also have an article on this : PostIncrementOperatorAndAssignment
 
viki Bhardwaj
Ranch Hand
Posts: 74
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:We also have an article on this : PostIncrementOperatorAndAssignment



Thanks! Seetharaman for sharing the valuable link ,...it was good enough explanation.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic