title: Generics in Collection
body: <p>Here is my program.  I am not sure why I am getting a compile time error.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  public class Test {
  public static void main(String[] args) {
      List&lt; ? extends Number &gt; list = new ArrayList&lt;Integer&gt;();
  
      list.add(6); // Compile Time Error
  
      System.out.println(list);
  
    }
  }
  </code></pre>
  
  <p>But the following program works fine</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  public class Test {
  public static void main(String[] args) {
      List&lt; ? super Number &gt; list = new ArrayList&lt;Number&gt;();
  
      list.add(6); 
  
      System.out.println(list);
  
      }
  }
  </code></pre>
  
  <p><strong>Error from Eclipse:</strong></p>
  
  <p>Here is the error description from Eclipse:</p>
  
  <blockquote>
    <p>The method add(int, capture#1-of ? extends Number) in the type List is not 
     applicable for the arguments (int)</p>
  </blockquote>