Implementing Good hashCode function in java? -
i know days inbuilt utilities available hashcodebuilder apache commons lang trying understand how implement myself , came across example of hascode function employee class @ http://en.wikipedia.org/wiki/java_hashcode() everywhere on google, same kind of technique suggested multiplying non 0 value odd prime number , summing instance variable(do instance variable). questions:- 1)why can't return employeeid hascode becoz aways unique. simple , serves hascode purpose. agreed if not unique need kind of technique. right? 2)even if employee id not unique, why suggested multiply odd prime number? why taking damn integer not considered good? update:- peter ran example mentioned printed [0, 32, 64, 96, 128, 160, 192, 224, 288, 256, 352, 320, 384] [0, 32, 64, 96, 128, 160, 192, 224, 288, 256, 352, 320, 384] i assume output yoy expected understand concept mentioned in answer [373, 343, 305, 275, 239, 205, 171, 137, 102, 68, 34, 0] [0, 34, 68, 102, 137, 171, 20...