List Method returns set
<p>I need some help with creating one small method which will take a list as a parameter and search through another list and if it matches with the parameter we pass then the method will return a set of matching entries. </p>

<p>Any input would be appreciated. I'm new to this forum. If I didn't post in correct category then I'm sorry please guide me to the right place.</p>

<p>getPopularNames(popular);</p>

<p>Here's my code:</p>

<pre><code>public List filterNames(List namesList){
    Set namesToExclude = new HashSet();
    List popular = new ArrayList();

    for (int i = 0; i &lt; namesList.size(); i++){
        NamesList criteria = new (NamesList) namesList.get(i);
        criteria.setPopularExclusionSet(popularExclusionSet);
        popular.add(criteria);
    }
        getPopularNames(popular);
}
</code></pre>
