goxr3plus / goxr3plus/java-google-speech-api

Always override hashCode when you override equals

Open
#8 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
80
Forks
35
PR merge metrics
No merged PRs in 30d

Description

https://github.com/goxr3plus/java-google-speech-api/blob/1863c920b637831f71d1d49f6f04a9396443fede/src/main/java/com/goxr3plus/speech/util/Complex.java#L116

See Effective Java by Josua Bloch, item 11.

This will fail in Junit5, and probably in Junit 4 and TestNG too:
assertEquals(new Complex(1, 0), new Complex(1, 0));

because the expected (left) and actual (right) values have different hash codes.

IntelliJ can make a working hashCode method for you in seconds.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.