title: Java diference between ++i and i++ with finally{}
body: <p>It's my first post and I know similar things were posted.... but i got a problem understanding something. I know the difference with ++i and i++</p>
  
  <ol>
  <li>++i first increments the 'i' then return value of 'i'</li>
  <li>i++ increments 'i' and returns value before it was incremented</li>
  </ol>
  
  <p>I got a question on Job interview:
  "What will be the value of i"</p>
  
  <pre><code>int test(){
     int i = 0;
     try {
      return i++; 
     } finally {
      return ++i;
     }
  }
  </code></pre>
  
  <p>According to what i wrote above, i thought it should be 1. But after checking it in some test app i know its 2. So my Question is: Why? </p>
  
  <p>When i played with it a little and switched ++i with i++</p>
  
  <pre><code>int test(){
     int i = 0;
     try {
      return ++i; 
     } finally {
      return i++;
     }
  }
  </code></pre>
  
  <p>In this case value of i is as expected 1. So why is that?</p>