title: Java 8 int array to map
body: <p>I want to convert <strong>int array</strong> to </p>
  
  <pre><code>Map&lt;Integer,Integer&gt; 
  </code></pre>
  
  <p>using Java 8 stream api</p>
  
  <pre><code>int[] nums={2, 7, 11, 15, 2, 11, 2};
  Map&lt;Integer,Integer&gt; map=Arrays
                  .stream(nums)
                  .collect(Collectors.toMap(e-&gt;e,1));
  </code></pre>
  
  <p>I want to get a map like below, key will be integer value, value will be total count of each key</p>
  
  <blockquote>
    <p>map={2->3, 7->1, 11->2, 15->1}</p>
  </blockquote>
  
  <p>compiler complains "<strong>no instance(s) of type variable(s) T, U exist so that Integer confirms to Function</strong>"</p>
  
  <p>appreciate any pointers to resolve this</p>