title: Java: Why can't I cast int to Long
body: <p>All numbers in Java are supposed to be of int type.
  The following line is legal in Java>1.5</p>
  
  <pre><code>Short s = 1; // Will compile to Short s = Short.valueOf((short)1) - thus you can't exceed short max value i.e.
  Short s =  4444; // is invalid for autoboxing
  </code></pre>
  
  <p>Same mechanics go for <code>Integer</code> and <code>Byte</code> instantiation. But Long works completely different. The following code gives compile time error</p>
  
  <pre><code>Long l = 10;
  </code></pre>
  
  <p>Long uses the same approach for autoboxing of long types, so</p>
  
  <pre><code>Long l = 10L; //is valid and is translated into Long.valueOf(10L)
  </code></pre>
  
  <p>I can't see why int cannot be assigned to a Long variable. Any thoughts on this matter?</p>