Yuriy Zubarev

Ominous hashCode() method


I just spent couple of hours debugging a subtle problem only to pinpoint the root cause to an erroneous implementation of hashCode() method. It was a nice refresher in Java basics. Here is the culprit:

  public int hashCode() {
    return super.hashCode() + (this.code == null ? 0 : this.code.hashCode());

Any guesses?


Comments :

blog comments powered by Disqus