Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override hashCode() when you override equals() #34

Closed
bbabic opened this issue May 23, 2013 · 2 comments
Closed

Override hashCode() when you override equals() #34

bbabic opened this issue May 23, 2013 · 2 comments

Comments

@bbabic
Copy link

bbabic commented May 23, 2013

As Java SDK suggests, you should override hashCode() too when you override equals(). This speeds up your code a bit, and most importantly, your code will not produce compiler warnings.

@hennr
Copy link
Collaborator

hennr commented May 23, 2013

Patches are welcome :)

@beckchr
Copy link
Contributor

beckchr commented May 23, 2013

Equal objects must have equal hash codes.

There are 11 classes implementing equals(Object) but not hashCode(). Someone should examine these classes and

  • remove the equals() implementation if it's not needed
  • add a hashCode() implementation otherwise

Eclipse can generate those methods (from the context menu, select "Source - Generate equals and hashCode").

mpatric added a commit that referenced this issue Nov 11, 2013
Issue #34: added missing hashCode() implementations
iNdieboyjeff pushed a commit to iNdieboyjeff/mp3agic that referenced this issue Nov 11, 2013
# By Christoph Beck
# Via Christoph Beck (1) and Michael Patricios (1)
* 'master' of https://github.com/mpatric/mp3agic:
  added missing hashCode() implementation, fixes mpatric#34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants