can getters be used in equals and hashcode?
<p>I have below code which overrides equals() and hashcode() methods.</p>

<pre><code>public boolean equals(Object obj)
 {
   if (obj == null)
     return false;
   if (!(obj instanceof Name))
     return false;
   Name name = (Name) obj;
   return this.name.equals(name.name);
 }

 public int hashCode()
 {
   return name.hashCode();
 }
</code></pre>

<p>here can i replace below 2 lines: </p>

<pre><code>return this.name.equals(name.name);
return name.hashCode();
</code></pre>

<p>with</p>

<pre><code>return this.getName().equals(name.getName());
return getName().hashCode();
</code></pre>

<p>i mean instead of using properties can i directly use getters inside equals and hashcode methods?</p>

<p>Thanks!</p>
