title: Java8 : How to filter a map of List value via stream
body: <p>I'm still a beginner of Java 8. I'm getting stuck on filtering a Map of List values. Here is my code</p>
  
  <pre><code>public class MapFilterList {
      private static Map&lt;String, List&lt;Person&gt;&gt; personMap = new HashMap&lt;&gt;();
  
      public static void main(String[] args) {
          Person p1 = new Person("John", 22);
          Person p2 = new Person("Smith", 45);
          Person p3 = new Person("Sarah", 27);
  
          List&lt;Person&gt; group1 = new ArrayList&lt;&gt;();
          group1.add(p1);
          group1.add(p2);
  
          List&lt;Person&gt; group2 = new ArrayList&lt;&gt;();
          group2.add(p2);
          group2.add(p3);
  
          List&lt;Person&gt; group3 = new ArrayList&lt;&gt;();
          group3.add(p3);
          group3.add(p1);
  
          personMap.put("group1", group1);
          personMap.put("group2", group2);
          personMap.put("group3", group3);
  
          doFilter("group1").forEach(person -&gt; {
              System.out.println(person.getName() + " -- " + person.getAge());
          });
  
      }
  
      public static List&lt;Person&gt; doFilter(String groupName) {
          return personMap.entrySet().stream().filter(key -&gt; key.equals(groupName)).map(map -&gt; map.getValue()).collect(Collectors.toList());
      }
  }
  </code></pre>
  
  <p>How can I make to correct <code>doFilter</code> method because the error show me <code>cannot convert from List&lt;List&lt;Person&gt;&gt; to List&lt;Person&gt;</code>.</p>