If two objects are equal according to the equals() method, then their hash codes must be equal as well.
If two objects have the same hash code, they may or may not be equal according to the equals() method.
equals
@Overridepublic boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Dog)) return false; Dog dog = (Dog) o; return getAge() == dog.getAge() && getName().equals(dog.getName()) && getBreed().equals(dog.getBreed()); }
hashCode
@Overridepublic int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + columnIndex; result = (prime * result) + rowIndex; return result;}