title: create map of int occurrences using Java 8
body: <p>I am aware my question is very similar to <a href="https://stackoverflow.com/questions/23925315/count-int-occurrences-with-java8">Count int occurrences with Java8</a>
  , but I still cannot solve my case, which must be easier to solve.</p>
  
  <p>The need is to count how many times integers repeat in a stream of integers (will be coming from a file, may be up to 1000000 integers). I thought it might be useful to create a map, where Integer will be a Key, and number of occurrences will be a value.</p>
  
  <p>The exception is </p>
  
  <blockquote>
    <p>Error:(61, 66) java: method collect in interface
    java.util.stream.IntStream cannot be applied to given types;<br>
    required:
    java.util.function.Supplier,java.util.function.ObjIntConsumer,java.util.function.BiConsumer
    found: java.util.stream.Collector>   reason: cannot
    infer type-variable(s) R
        (actual and formal argument lists differ in length)</p>
  </blockquote>
  
  <p>However, in Java 8 there is a <code>Collectors.groupingBy</code>, which should suffice</p>
  
  <pre><code> Collector&lt;T, ?, Map&lt;K, D&gt;&gt; groupingBy(Function&lt;? super T, ? extends K&gt; classifier,Collector&lt;? super T, A, D&gt; downstream) 
  </code></pre>
  
  <p>The problem is that my code is not compiling and I do not see - why.
  I simplified it to this:</p>
  
  <pre><code>Map&lt;Integer,Integer&gt; result = IntStream.range(0,100).collect(Collectors.groupingBy(Function.identity(), Collectors.counting())); 
  </code></pre>
  
  <p>What is the reason for not compiling?
  Thank you in advance :)</p>