If I run the below code then the output is 2 which means that the set contains 2 elements. However I think that set should contain 1 since both the objects are equal based o
The @Overrides annotation is to override the method with the same name in the super class".
@Override
public int hashCode() {
return a;
}
@Override
public boolean equals(Object obj) {
return (obj instanceof Alpha && ((Alpha) obj).a == this.a);
}
@Override
public String toString() {
return "Alpha : " + a;
}