Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

question about x++ and x--

843785Aug 25 2008 — edited Aug 25 2008
int x = 1;
       int y = 0;
       y = x++ + x++ - x-- - ++x;
      System.out.println(x + " " + y);
it return me 3 , -3

how do you calculate that..
i know ++x means add 1 b4 adding
I just don't get why x++ means add 1 after the calculation and why ++x means before
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 22 2008
Added on Aug 25 2008
7 comments
208 views