title: Cannot cast java.lang.Integer to int
body: <p>I'm confused by the following Java code, in which I try to use two methods to cast an Object to an int:</p>
  
  <pre><code>Object o = 1;
  System.out.println((int) o);
  Class &lt;?&gt; t = int.class;
  System.out.println(t.cast(o));
  </code></pre>
  
  <p>The second line casts the <code>Object</code> to an <code>int</code> traditionally, and succeeds. The fourth, however, which I would expect to be functionally equivalent, throws</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: Cannot cast java.lang.Integer to int
  </code></pre>
  
  <p>What's the functional difference between the second line and the fourth? Why would one fail while the other succeeds?</p>