Anonymous Overriding HashSet hashCode
<p>I'm trying to use a <code>HashSet</code> to remove the duplicates from a list of <code>ApplicationInfo</code> objects and I'm trying to use more advanced ways to accomplish this than the good old loop and compare.</p>

<p>I've been recently learning about the anonymous abilities in Java and I'm trying to apply that here but I'm stuck. From what I understand, <code>equals()</code> simply uses the <code>hashCode()</code> method to determine equality and from what I could gather I would only need to override the <code>hashCode()</code> method.</p>

<p>Within the <code>ApplicationInfo</code> object is a field called <code>packageName</code>, a string, which is the ONLY field I want the <code>HashSet</code> to compare and exclude any duplicates.</p>

<p>Since I'm new to Java, I'd love some help understanding if I'm understanding this right and either way, how to do this. I realize I could extend <code>HashSet</code> and do it that way but I want to try this Anonymous deal so I learn something.</p>

<p>If I have a HashSet containing ApplicationInfo objects, how do I return a hashCode based on the packageName field?</p>

<pre><code>//Help me fix the below idea please
HashSet&lt;ApplicationInfo&gt; hs = new HashSet&lt;ApplicationInfo&gt;() {
        @Override
        public int hashCode() {
            // How do I do this sort of thing
            return this.packageName.hashCode();
    }
};
</code></pre>
