title: How does implicit conversion work in Java?
body: <p>I know that in Java Integer literals are <em>int</em> by default,so if I write something like this</p>
  <pre><code>byte byteValue = 2;
  </code></pre>
  <p>Java auto converts the literal value <strong>2</strong>(which is an int by default) to byte.
  And the same thing works if  I write</p>
  <pre><code>byte byteValue = 4/2;
  </code></pre>
  <p>The RHS is evaluated as an int and implicitly converted to a byte.</p>
  <p><strong>But why doesn't implicit conversion happen in the below two cases?</strong></p>
  <pre><code>int n1 = 4;
  byte value = n1/2;
  </code></pre>
  <p>OR in this</p>
  <pre><code>byte n1 = 4;
  byte value = n1/2;
  </code></pre>
  <p>I know that the RHS of both these examples are evaluated as an <em>int</em>. But why doesn't Java convert it to a byte implicitly like it did in the first two cases.Does implicit conversion to smaller data type happen only if there are literals?</p>