title: The method countGreaterThan(T[], T) in the type GenericMethodsAndBoundedTypeParameters is not applicable for the arguments (Integer[], Integer)
body: <p>Update:</p>
  <p>This question came up while I was learning Java Generics from the Oracle Java Tutorials, the codes were from <a href="https://docs.oracle.com/javase/tutorial/java/generics/boundedTypeParams.html" rel="nofollow noreferrer">https://docs.oracle.com/javase/tutorial/java/generics/boundedTypeParams.html</a>, and this led me to the following error. I didn't know that Java already has the Comparable interface at that time. Problem was solved right after I removed my own Comparable interface.</p>
  <p>Original post:</p>
  <p>I am having trouble fixing the error in the following code. I am using JavaSE-16 on Eclipse 2021-09</p>
  <pre><code>public class GenericMethodsAndBoundedTypeParameters {
      public static void main(String[] args) {
          int a = countGreaterThan(new Integer[] {1, 2, 3, 4, 5}, (Integer)(2));
      }
      public static &lt;T extends Comparable&lt;T&gt;&gt; int countGreaterThan(T[] anArray, T elem) {
          int count = 0;
          for(T e : anArray) {
              if(e.compareTo(elem) &gt; 0) {
                  ++count;
              }
          }
          return count;
      }
  }
  
  interface Comparable&lt;T&gt; {
      public int compareTo(T obj);
  }
  </code></pre>
  <p>The error message looks like this:</p>
  <p><strong>The method countGreaterThan(T[], T) in the type GenericMethodsAndBoundedTypeParameters is not applicable for the arguments (Integer[], Integer)</strong></p>