I have (at least) two classes that implement the same interface and have the same fields. Is it ok if those two classes have the same hash code if their fields are identical or should they be different? Is this code ok?
interface Base { }
class A implements Base {
private Integer value;
public A(Integer value) { this.value = value; }
public int hashCode() { return value.hashCode(); }
}
class B implements Base {
private Integer value;
public B(Integer value) { this.value = value; }
public int hashCode() { return value.hashCode(); }
}