title: Why can't mapToInt be used with collect(toList())?
body: <p>I wrote this code:</p>
  
  <pre><code>import java.util.*;
  import java.util.stream.Collectors;
  
  public class Main {
  
      public static void main(String... args) {
          List&lt;String&gt; a = Arrays.asList("One", "Two", "three");
          List&lt;Integer&gt; lengths = a.stream().mapToInt(String::length).collect(Collectors.toList());
  
      }
  }
  </code></pre>
  
  <p>but it doesn't want to compile, saying:</p>
  
  <pre><code>Error:(8, 68) java: method collect in interface java.util.stream.IntStream cannot be applied to given types;
    required: java.util.function.Supplier&lt;R&gt;,java.util.function.ObjIntConsumer&lt;R&gt;,java.util.function.BiConsumer&lt;R,R&gt;
    found: java.util.stream.Collector&lt;java.lang.Object,capture#1 of ?,java.util.List&lt;java.lang.Object&gt;&gt;
    reason: cannot infer type-variable(s) R
      (actual and formal argument lists differ in length)
  </code></pre>
  
  <p>What's happening here? Why the limitation? If you use map. Instead of mapToInt, it works fine.</p>