title: Unary operators in java vs c++
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc">Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc&hellip;)</a><br>
    <a href="https://stackoverflow.com/questions/6623888/is-there-any-difference-between-the-java-and-c-operators">Is there any difference between the Java and C++ operators?</a>  </p>
  </blockquote>
  
  
  
  <p>Why unary operators give different result in c++ and java?</p>
  
  <p>Check this out:</p>
  
  <pre><code>int i = 1;
  i = i++ + ++i;
  print i  (with cout or println)
  </code></pre>
  
  <p>In <strong>java</strong>: prints <strong>4</strong></p>
  
  <p>In <strong>c++</strong>: prints <strong>5</strong></p>
  
  <p>Why ?</p>