Can you show me an example of incorrect implementation of hashCode? I mean implementation which causes, that JVM is not able to locate the object in given collection.
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: