Java: Prefix/postfix of increment/decrement operators? Need help with example
<p>From the program below or <a href="http://download.oracle.com/javase/tutorial/java/nutsandbolts/examples/PrePostDemo.java" rel="nofollow">here</a>, why is the last System.out.println(i) going to print out 7?  Since the variable i hasn't been updated since ++i, shouldn't it be equal to 5?  I must be missing something..  Thanks.. </p>

<pre><code>class PrePostDemo {
     public static void main(String[] args){
          int i = 3;
      i++;
      System.out.println(i);    // "4"
      ++i;             
      System.out.println(i);    // "5"
      System.out.println(++i);  // "6"
      System.out.println(i++);  // "6"
      System.out.println(i);    // "7"
     }
}
</code></pre>
