Iterating through the elements of a HashSet containing user defined objects and displaying the elements that meet a certain criteria
<pre><code>public class AnotherCompany {

    public static void main(String[] args) {
        HashSet&lt;Employee&gt; h = new HashSet&lt;Employee&gt;();
        Employee e0 = new Employee("Mayank","IT",50000,10,10,10);
        Employee e1 = new Employee("Dhruv","IT",50000,10,10,10);
        Employee e2 = new Employee("Mayank","Accounts",50000,10,10,10);
        Employee e3 = new Employee("Mayank","IT",50000,10,10,10);
        h.add(e0);
        h.add(e1);
        h.add(e2);
        h.add(e3);
        e0.display(h,"IT");
    }
}
</code></pre>

<p>Now if I have to write a display method which displays only those employees that work in the IT department,What do I do?</p>