title: Hashmap with Streams in Java 8 Streams to collect value of Map
body: <p>Let consider a hashmap</p>
  <pre><code>Map&lt;Integer, List&gt; id1 = new HashMap&lt;Integer,List&gt;();
  </code></pre>
  <p>I inserted some values into both hashmap.</p>
  <p>For Example,</p>
  <pre><code>List&lt;String&gt; list1 = new ArrayList&lt;String&gt;();
  
  list1.add(&quot;r1&quot;);
  list1.add(&quot;r4&quot;);
  
  List&lt;String&gt; list2 = new ArrayList&lt;String&gt;();
  list2.add(&quot;r2&quot;);
  list2.add(&quot;r5&quot;);
  
  List&lt;String&gt; list3 = new ArrayList&lt;String&gt;();
  list3.add(&quot;r3&quot;);
  list3.add(&quot;r6&quot;);
  
  id1.put(1,list1);
  id1.put(2,list2);
  id1.put(3,list3);
  id1.put(10,list2);
  id1.put(15,list3);
  </code></pre>
  <p>Q1)    Now I want to apply a filter condition on the key in hashmap and retrieve the corresponding value(List).</p>
  <p>Eg: Here My query is key=1, and output should be 'list1'</p>
  <p>I wrote</p>
  <pre><code>id1.entrySet().stream().filter( e -&gt; e.getKey() == 1);
              
  </code></pre>
  <p>But I don't know how to retrieve as a list as output of this stream operation.</p>
  <p>Q2)        Again I want to apply a filter condition on the key in hashmap and retrieve the corresponding list of lists.</p>
  <p>Eg:  Here My query is key=1%(i.e key can be 1,10,15), and output should be 'list1','list2','list3'(list of lists).</p>