title: Getting only required objects from a list using Java 8 Streams
body: <p>Consider a <code>Parent</code> class with the attributes <code>attrib1</code>, <code>attrib2</code> and <code>List&lt;Child&gt;</code> child with its corresponding getters and setters.</p>
  
  <p>The <code>Child</code> is another class with five attributes <code>attrib1</code>-<code>attrib5</code> with its corresponding getters and setters.</p>
  
  <p>Now I created a <code>List&lt;Parent&gt;</code> parent. Then I want to filter out a <code>List&lt;Parent&gt;</code> with following condition:- <code>Child.Attrib1 &gt; 10</code>;</p>
  
  <p>So I created the following query by Java 8 streams.</p>
  
  <pre><code>parent.stream().filter(e -&gt; e.getChild().stream().anyMatch(c -&gt; c.getAttrib1() &gt; 10));
  </code></pre>
  
  <p>But the problem is I will get all the child in each <code>Parent</code> object. Here I want to get only those child object in <code>List&lt;Child&gt;</code> that obeys the given condition.</p>
  
  <p>How should I remove all the child objects in List that doesn't obeys the condition and get the new List. </p>