title: OO/Generics with Numbers
body: <p>I have this scenario, but why java is not respecting the class hierarchy?</p>
  
  <pre><code>import ...
  
  public class GenericsTest {
  
      public static void main(String[] args) {
          List&lt;Integer&gt; myList = new ArrayList&lt;Integer&gt;();
          myList.add(1);
          myList.add(new Integer(2));
          new GenericsTest().doInsert(myList);
      }
  
      private void doInsert(List&lt;? extends Number&gt; myList) { // Number &lt;- Integer
          myList.add(new Integer(1)); // This don't compiles
      }
  }
  </code></pre>
  
  <p>Can someone explains this?
  Thanks!!!</p>