I have the code below that overrides the equals () and hashcode () methods.
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(); }
here I can replace below two lines:
return this.name.equals(name.name); return name.hashCode();
from
return this.getName().equals(name.getName()); return getName().hashCode();
Does i mean that instead of using properties, can i directly use getters inside peers and hash code methods?
Thanks!
source share