title: Problem with <T extends Comparable<? super T>>
body: <p>I have a three class: 1.class <code>Algorithm</code> having <code>max()</code> finding maximum value in a <code>Collection</code>:</p>
  
  <pre><code>public class Algorithm {
  
      public static &lt;T extends Comparable&lt;T&gt;&gt; T max(Collection&lt;? extends T&gt; coll) {
          T max = coll.iterator().next();
  
          for (T elm : coll) {
              if (max.compareTo(elm) &lt; 0)
                  max = elm;
          }
  
          return max;
      }
  }
  </code></pre>
  
  <p>2.Class <code>Fruit</code>:</p>
  
  <pre><code>public class Fruit implements Comparable&lt;Fruit&gt; {
      private String name;
      private int size;
  
      public Fruit(String name, int size) {
          this.name = name;
          this.size = size;
      }
  
      public int compareTo(Fruit that) {
          if (size &lt; that.size)
              return -1;
          else if (size == that.size)
              return 0;
          else
              return 1;
      }
  }
  </code></pre>
  
  <p>3.class <code>Apple</code> extending <code>Fruit</code>:</p>
  
  <pre><code>public class Apple extends Fruit {
      public Apple(int size) {
          super("Apple", size);
      }
  }
  </code></pre>
  
  <p>Now the question is this:</p>
  
  <pre><code>public class Main
  {
      public static void main(String[] args) {        
          Apple a1 = new Apple(10);
          Apple a2 = new Apple(34);
  
          List&lt;Apple&gt; apples = Arrays.&lt;Apple&gt;asList(a1, a2);
  
          System.out.println(Collections.max(apples).size);
      }
  }
  </code></pre>
  
  <p>According to this post <a href="https://stackoverflow.com/questions/2827585/java-syntax-question-what-is-super-t">Java - Syntax Question: What is </a> I should wrote it this way: <code>public static &lt;T extends Comparable&lt;? super T&gt;&gt; T max(Collection&lt;? extends T&gt; coll)</code>. But it is working fine now.Why? Class <code>Apple</code> does not implement <code>Comparable&lt;Apple&gt;</code> and there is no <code>super</code>.</p>
  
  <p>[UPDATE]<br>
  Java Generics and Collections Book says:</p>
  
  <blockquote>
    <p>Without the <code>super</code> wildcard, finding the maximum of a <code>List&lt;Apple&gt;</code>
    would be illegal, even though finding the maximum of a <code>List&lt;Fruit&gt;</code> is
    permitted.</p>
  </blockquote>