Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference in output

 
Phillipe Rodrigues
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why i am getting different outputs for the below programs?

Program1:


Output:
---------- RUN ----------
5

Output completed (0 sec consumed) - Normal Termination

----------------------------------------------------------------------
Program 2:


Output:
---------- RUN ----------
6

Output completed (0 sec consumed) - Normal Termination
 
Rob Spoor
Sheriff
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're using the postfix increment operator. That returns the old value before incrementing. The prefix increment operator (++a) will return the new increased value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic