aspose file tools
The moose likes Beginning Java and the fly likes Difference in output Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Difference in output" Watch "Difference in output" New topic
Author

Difference in output

Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
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


Thanks,
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Difference in output
 
Similar Threads
Compile time erroe in the code.
constructor
Math.round( -.5)?
Arithmetic Compound Assignment Operators..
about contructor