title: Java Generic type : difference between List <? extends Number> and List <T extends Number>
body: <p>Java Generic type : what is the difference between </p>
  
  <pre><code>(1) List &lt;? extends Number&gt;   
  (2) List &lt;T extends Number&gt;
  </code></pre>
  
  <p>as per my understanding</p>
  
  <p>(1) <code>List &lt;? extends Number&gt;</code>  is the 
  Readonly List of "unknown" data type with super class "Number". we can read the element only but can not add</p>
  
  <p>(2) <code>List &lt;T extends Number&gt;</code>
  List of data type with super class "Number". we can <strong>read and add</strong> the elements into the list</p>
  
  <p>Please see the below code example</p>
  
  <pre><code>class TestGen{
  
      public static void main(String[] args) {
          double result = 0.0;
  
          List&lt;Integer&gt; intList = new ArrayList&lt;Integer&gt;();
          intList.add(10);
          intList.add(20);
          intList.add(30);
  
          result = TestGen.sumOfList1(intList);
          System.out.println("Result=" + result);
          result = TestGen.sumOfList2(intList);
          System.out.println("Result=" + result);
      }
  
      public static double sumOfList1(List&lt;? extends Number&gt; list) {
          double s = 0.0;
          for (Number n : list)
              s += n.doubleValue();
          return s;
      }
  
      public static &lt;T extends Number&gt; double sumOfList2(List&lt;T&gt; list) {
          double s = 0.0;
  
          // getting error while trying to add new element 
          // list&lt;T&gt; is not applicable for argument(Integer) : Why ?
          list.add(new Integer(40));
  
          for (Number n : list)
              s += n.doubleValue();
  
          return s;
      }
  }
  </code></pre>
  
  <p>When I am trying to add the Integer (or even Number object) into the sumOfList2 then getting the error. Please explain what is wrong here ?</p>