title: Using List Stream filter vs for loop
body: <p>In java 8 you can now use filter on a list to get another list based on the <code>Predicate</code> you supply.</p>
  
  <p>so lets say I have normal for loop logic like this</p>
  
  <pre><code>for(Person p : personList){
      if(p.getName().Equals("John")){
           //do something with this person
      }
  }
  </code></pre>
  
  <p>now using a filter like this</p>
  
  <pre><code>List&lt;Person&gt; johnList = personList.stream()
      .filter(p -&gt; p.getName().Equals("John"))
      .collect(Collectors.toList()); 
  
  for(Person john : johnList){
      //do something with this person
  }
  </code></pre>
  
  <p>it seems like using a filter would cause more overhead than using just a regular for loop because its not only looping through the entire list the first time but then you have to loop through the filtered list and do what you want with that filtered list.</p>
  
  <p>Am I incorrect in how this works?</p>