/** * hashCode that combines two strings * @return a hash code value on the pair of strings. */ public int hashCode() { int result = string1.hashCode(); result = 37 * result + string2.hashCode(); result = 37 * result + string3.hashCode(); // etc for all fields in the object // This will only work for 5 fields before you overflow and lose input from the first field. // The optimal prime multiplier is near Math.exp( Math.log( Integer.MAX_VALUE ) / numberOfFields) ) // This technique samples output from all the component Objects but mushes it together with information form the other fields. return result; }