title: Convert List<Long> to Map<Long, Long> that counts occurrences
body: <p>I'm playing around with Java 8 and I know that this must be possible by reading the documentation, I just cannot find out how to do it.</p>
  
  <p>I have the following working code:</p>
  
  <pre><code>    long factorProduct = LongStream.rangeClosed(1, maxFactor)
              .filter(this::isOptimalFactor)
              .reduce((i, j) -&gt; i * j)
              .getAsLong();
      List&lt;Long&gt; primeFactors = primeFactors(factorProduct);
  </code></pre>
  
  <p>Important part is that I have a <code>List&lt;Long&gt;</code> that <em>may</em> have duplicates on some <code>Long</code> numbers.</p>
  
  <p>Now I want to convert it to a <code>Map&lt;Long, Long&gt;</code> with as key the element and as value the occurences.</p>
  
  <p>I thought that: </p>
  
  <pre><code>    Map&lt;Long, Long&gt; primeFactorCount = primeFactors.stream()
              .collect(Collectors.counting());
  </code></pre>
  
  <p>would work, but it doesn't. I looked up the examples <a href="http://download.java.net/jdk8/docs/api/java/util/stream/Collectors.html" rel="nofollow">in the java.util.stream.Collectors documentation</a>.</p>
  
  <p>How do I need to use these features?</p>