Type casting and automatic type promotion in Java
<p>Let's consider some simple expressions in Java.</p>

<pre><code>byte var=0;

var=(byte)(var+1);
</code></pre>

<hr>

<p>Here, in the above statement, obviously type casting is needed because of automatic type promotion. </p>

<p>The evaluation of the expression <strong>(var+1)</strong> is automatically promoted to int hence, must explicitly be cast to byte to assign the outcome of it to a byte variable on the right of the assignment which is <strong>var</strong>     </p>

<hr>

<p>Now, let's consider the following statement in Java.</p>

<pre><code>var++;
</code></pre>

<p>This is somewhat equivalent to the previous statement and should have needed a cast though it works without a cast. Why?</p>

<hr>

<p>Even the following statement doesn't require a cast. Why?</p>

<pre><code>byte x=var++;
</code></pre>
