hashCode()
hashCode()λ κ°μ²΄μ λμΌμ±μ νλ¨νλ€.
Javaμ hashCode
μμ
@Test
@DisplayName("κ°μ κ°μ²΄λ₯Ό hashCode λΉκ΅")
void hash() {
Ball ball = new Ball("1");
Ball ball2 = new Ball("1");
System.out.println(ball.hashCode());
System.out.println(ball2.hashCode());
Assertions.assertThat(ball.hashCode()).isEqualTo(ball2.hashCode());
}
// fail
Expected :1484531981
Actual :17037394Last updated