This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
This could also be one more incorrect implementation of hashCode().
hashCode() returning jst constant value like below is also not a gud implementation.
returning hashCode() value as 1 is not a very gud design becoz in this case, all the objects will land in the same bucket and in that case whole searching operation must be performed by .equals(Object) method. In Short, Map is not efficient in searching.
Implement hashCode() in such a way that all objects land in different buckets would be a gud design in terms of efficiency of the Map.
It's hard to define one that's incorrect in isolation because its correctness is tied up with the definition of equals() in the same class. This one comes pretty close to being utterly incorrect, though, in the sense that the value returned is utterly useless: