title: Java generics - special case of extended and super usage
body: <p>Is there any conceptual difference between these two methods?</p>
  
  <pre><code>public static &lt;T&gt; void add1(final Collection&lt;T&gt; drivers, final Collection&lt;? super T&gt; persons) {
      persons.addAll(drivers);    
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public static &lt;T&gt; void add2(final Collection&lt;? extends T&gt; drivers, final Collection&lt;T&gt; persons) {
      persons.addAll(drivers);    
  }
  </code></pre>
  
  <p>The following main method compiles without any warnings and executes without any runtime-exceptions. And the result is the expected one - 4.</p>
  
  <pre><code>public static void main(String[] args) {
      final Person person1 = new Person();
      final Person person2 = new Person();
      final Collection&lt;Person&gt; persons = new ArrayList&lt;&gt;();
      persons.add(person1);
      persons.add(person2);
  
      final Driver driver1 = new Driver();
      final Collection&lt;Driver&gt; drivers = new ArrayList&lt;&gt;();
      drivers.add(driver1);
  
      add1(drivers, persons);
      add2(drivers, persons);
  
      System.out.println(persons.size());
  }
  </code></pre>
  
  <p>I am aware of PECS principle, and since <code>persons</code> in the first method is a consumer, <code>super</code> should be use, respectively - <code>extends</code> should be used for <code>drivers</code> in the second method. But is there any gotchas? Any difference that I may miss? If not, which one of the versions is preferred, and why?</p>