title: List<?> vs List<? extends Object>
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8055389/whats-the-difference-between-and-extends-object-in-java-generics">What’s the difference between &lt;?&gt; and &lt;? extends Object&gt; in Java Generics?</a>  </p>
  </blockquote>
  
  
  
  <p>I found that <code>List&lt;?&gt;</code>and <code>List&lt;? extends Object&gt;</code> act in the same way. As for me, there are no difference between them. If I am not right, can you explain me the difference?</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  public class TestClass {
  
  static void func1(List&lt;?&gt; o, Object s) {
      o.add(null); // only null
      o.add(s); // wrong
      o.get(0);  // OK
  }
  
  static void func2(List&lt;? extends Object&gt; o, Object s) {
      o.add(null); // only null
      o.add(s); // wrong
      o.get(0); // OK
  }
  
  public static void main(String[] args) {
      func1(new ArrayList&lt;String&gt;(), new Integer(1));
      func2(new ArrayList&lt;String&gt;(), new Integer(1));
  
      List&lt;? extends Object&gt; list1 = new ArrayList&lt;Object&gt;();
      List&lt;?&gt; list2 = new ArrayList&lt;Object&gt;();
  
      List&lt;? extends Object&gt; list3 = new ArrayList&lt;String&gt;();
      List&lt;?&gt; list4 = new ArrayList&lt;String&gt;();
  }
  }
  </code></pre>