All objects have a hashCode () method called by HashSet, HashMap, ecc ..
You can override this method to define your own logic.
@Override public int hashCode() { return <<MY CODE HERE>>; }
or, more simply, iterate over your HashSet and check the hashCode () value
int myHash = 123; for(Object o:mySet){ if(myHash == o.hashCode()){
source share