title: Filter based on condition and collect the object
body: <p>In java 8, collect emp object based on some filter condition.</p>
  <p>In main class:</p>
  <pre class="lang-java prettyprint-override"><code>List&lt;Emp&gt; empList = Arrays.asList(
      new Emp(&quot;aaa&quot;, language1), 
      new Emp(&quot;cc&quot;, language2),
      new Emp(&quot;bb&quot;, language3), 
      new Emp(&quot;dd&quot;, language3)
  );
  
  empList.stream()
      .flatMap(s-&gt;s.getLanguage().stream())
      .filter(s-&gt;s.equals(&quot;java&quot;))
      .forEach(System.out::println); //Here just i am printing. 
  </code></pre>
  <p>Actually I need to collect <code>new List&lt;EMP&gt;</code>.</p>
  <p>How to collect emp object that are all have language &quot;java&quot;. How can I do this?</p>