aspose file tools*
The moose likes Beginning Java and the fly likes Difference in output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
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: 19761
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Difference in output