<p>I noticed the specificaition for Collections.sort:</p>

<pre><code>public static &lt;T&gt; void sort(List&lt;T&gt; list, Comparator&lt;? super T&gt; c)
</code></pre>

<p>Why is the "<code>? super</code>" necessary here?  If <code>ClassB</code> extends <code>ClassA</code>, then wouldn't we have a guarantee that a <code>Comparator&lt;ClassA&gt;</code> would be able to compare two <code>ClassB</code> objects anyway, without the "<code>? super</code>" part?</p>

<p>In other words, given this code:</p>

<pre><code>List&lt;ClassB&gt; list = . . . ;
Comparator&lt;ClassA&gt; comp = . . . ;
Collections.sort(list, comp);
</code></pre>

<p>why isn't the compiler smart enough to know that this is OK even without specifying "<code>? super</code>" for the declaration of Collections.sort()?</p>

Josh Bloch had a talk at Google I/O this year, called
Effective Java Reloaded
, which you may find interesting. It talks about a mnemonic called "Pecs" (producer
```
extends
```
, consumer
```
super
```
), which explains why you use
```
? extends T
```
and
```
? super T
```
in your input parameters (only; never for return types), and when to use which.