title: Cannot infer type arguments for Class<>
body: <p>I have a problem with my sorting-test app, where I use a comparator.
  I got a message: </p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
        Cannot infer type arguments for Sorter&lt;></p>
  </blockquote>
  
  <p>For that code:</p>
  
  <pre><code>public class TestClass {
  
      public static void main(String[] args){
  
              Sorter&lt;Person&gt; idSorter = new Sorter&lt;&gt;(new idComparator());
      .
      .
      .
      }
  }
  </code></pre>
  
  <p>Sorter class:</p>
  
  <pre><code>public class Sorter&lt;T extends Comparable&gt; {
  
      Comparator&lt;T&gt; comparator;
      int switches = 0,
          compares = 0;
  
      public Sorter(Comparator&lt;T&gt; comparator) {
          this.comparator = comparator;
      }
  
      public Sorter() {
          this.comparator = null;
      }
  
      protected int compare(T first, T second) {
          if (this.comparator == null) {
              int cmp = first.compareTo(second);
              this.compares++;
              return cmp;
          }
  </code></pre>
  
  <p>Comparable interface: </p>
  
  <pre><code>public interface Comparable {
      public int compareTo(Comparable other);
  }
  </code></pre>
  
  <p>idComparator class:</p>
  
  <pre><code>public class idComparator implements Comparator&lt;Integer&gt; {
  
      public int compare(Integer first, Integer second) {
          return first &gt; second? 1: first == second? 0: 1;
      }
  }
  </code></pre>
  
  <p>Comparator interface:</p>
  
  <pre><code>public interface Comparator&lt;T&gt; {
      int compare(T first, T second);
  }
  </code></pre>
  
  <p>What is wrong with such a use? How can I do it better?</p>