title: Why Comparator.comparingInt not working in Arrays.sort() in Java?
body: <p>I am trying to sort a list of Interval class:</p>
  
  <pre><code>class Interval {
      int start;
      int end;
      Interval() { start = 0; end = 0; }
      Interval(int s, int e) { start = s; end = e; }
  }
  </code></pre>
  
  <p>I tried to use the code below:</p>
  
  <pre><code>Arrays.sort(intervals, Comparator.comparingInt(interval -&gt; interval.start));
  </code></pre>
  
  <p>but it has compiling errors:</p>
  
  <pre><code>java: no suitable method found for sort(java.util.List&lt;Interval&gt;,java.util.Comparator&lt;java.lang.Object&gt;)
      method java.util.Arrays.&lt;T&gt;sort(T[],java.util.Comparator&lt;? super T&gt;) is not applicable
        (cannot infer type-variable(s) T
          (argument mismatch; java.util.List&lt;Interval&gt; cannot be converted to T[]))
      method java.util.Arrays.&lt;T&gt;sort(T[],int,int,java.util.Comparator&lt;? super T&gt;) is not applicable
        (cannot infer type-variable(s) T
          (actual and formal argument lists differ in length))
  </code></pre>
  
  <p>However, when I use:</p>
  
  <pre><code>intervals.sort(Comparator.comparingInt(interval -&gt; interval.start));
  </code></pre>
  
  <p>it's working properly.</p>
  
  <p>Any reasons behind this?</p>