If y = 1 and y = y++, why when I print y is the value 1?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/7911776/what-is-x-after-x-x">What is x after &ldquo;x = x++&rdquo;?</a>  </p>
</blockquote>



<pre><code>int y = 1;
y = y++;
System.out.println("Value Of y :"+y);
</code></pre>

<p>The output is 
Value Of y : 1</p>

<p>I am incrementing the y and assigning that to "y" again.
y++ hence first the value is used and then it increments the value.
Hence it assign the value and it gets incremented. So I thought the output would be 2.</p>

<pre><code>int y = 1;
int x = y++;
System.out.println("Value Of x :"+x);
System.out.println("Value Of y :"+y);
</code></pre>

<p>The output is:<br>
Value Of x : 1<br>
Value Of y : 2</p>

<p>In this case it is working. I mean the way I thought is correct.</p>

<p>Can any one please explain to me why?</p>
