I'm trying to create a hash function for my own custom class. It uses a string value of 4 chars as a key, which is unique to every object, which I then encode using getBytes(), the part actually used to calculate to the hash value
public int hashCode() {
String fixedISBN = getIsbn().toString().replace("-", "");
fixedISBN = fixedISBN.substring(fixedISBN.length() - 4, fixedISBN.length());
byte[] binary = fixedISBN.getBytes();
String result = "";
for(byte b: binary){
result += b;
}
int hashValue = Integer.parseInt(result);
return hashValue * 53;
}
fixedISBN will always be a number ranging from somewhere between 1-9999. so fixedISBN for one object of this class can be 3321 will another object's fixed ISBN can be 209. Will this amount to a good hash function?