title: Widening and Boxing Java primitives
body: <p>Widening and Boxing Java primitives. </p>
  
  <p>I know it is not possible to widen a wrapper class from one to another as they are not from the same inheritence tree. Why though is it not possible to widen a primitive to another primitive type and autobox the widened primitive? </p>
  
  <p>Given that a byte argument can be passed to a method that expects an int, why cant the byte in the following example be widened to an int and then boxed to an Integer?</p>
  
  <pre><code>class ScjpTest{
      static void goInteger(Integer x){
          System.out.println("Going with an Integer");
      }
  
      static void goInt(int x){
          System.out.println("Going with an int");
      }
  
      public static void main(String args[]){
          byte b = 5;
          goInt(b);
          goInteger(b);
      }
  }
  </code></pre>
  
  <p>In the above example, <code>goInt(b)</code> is accepted by the compiler but <code>goInteger(b)</code> is rejected. </p>