Extract elements from list based on object property type
<p>Often, I have a list of objects.  Each object has properties.  I want to extract a subset of the list where a specific property has a predefined value.</p>

<p>Example:</p>

<p>I have a list of User objects.  A User has a homeTown.  I want to extract all users from my list with "Springfield" as their homeTown.</p>

<p>I normally see this accomplished as follows:</p>

<blockquote>
  <p>List users = getTheUsers();</p>
  
  <p>List returnList = new ArrayList(); </p>
  
  <p>for (User user: users) { </p>

<pre><code>   if ("springfield".equalsIgnoreCase(user.getHomeTown()) 

        returnList.add(user); 
</code></pre>
  
  <p>}</p>
</blockquote>

<p>I am not particularly satisfied with this solution.  Yes, it works, but it seems so slow.  There must be a non-linear solution.</p>

<p>Suggestions?</p>
