title: How to get the count of keys for values in a hash map using lambda
body: <p>I have a hash map </p>
  
  <pre><code>Map&lt;Integer, List&lt;String&gt;&gt; Directmap = new HashMap&lt;Integer, List&lt;String&gt;&gt;() {{
      put(0, Arrays.asList(a, b));
      put(1, Arrays.asList(b, c));
      put(2, Arrays.asList(d));
      put(3, Arrays.asList(d, e));
      put(4, Arrays.asList(e));
      put(5, Arrays.asList());
  }};
  </code></pre>
  
  <p><code>Directmap: {0=[a, b], 1=[b, c], 2=[d], 3=[d, e], 4=[e], 5=[]}</code> </p>
  
  <p>I want to count the number of keys for each value. For example: <code>"a"</code> has one key, <code>"b"</code> has two keys, ..., <code>"e"</code> has two keys namely 3 and 4.</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>Map&lt;Object, Long&gt; ex = Directmap.entrySet().stream()
              .collect(Collectors.groupingBy(e -&gt; e.getKey(), Collectors.counting()));
  </code></pre>
  
  <p>I want the values with number of keys as the output. Like this :</p>
  
  <pre><code>a=[1], b=[2], c=[1], d=[2], e=[2]
  </code></pre>