title: java stream collect function giving error
body: <p>First statement works but not second giving below error, why ?</p>
  
  <pre><code>java.util.Arrays.asList(1,2,3,4,5).stream()
                                    .map(n -&gt; n+1)
                                    .collect(Collectors.toList());
  
  List&lt;Integer&gt; list = IntStream.rangeClosed(1, 10)
                                .map(n -&gt; n + 1)
                                .collect(Collectors.toList());
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>Type mismatch: cannot convert from Collector&lt;Object,capture#5-of ?,List&lt;Object&gt;&gt; 
  to Supplier&lt;R&gt;
  </code></pre>