| 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
|
 |
 |
|
|
subject: Difference in output
|
|
|