본문 바로가기

카테고리 없음

hashcode 의 필요성 모든 object 와 비교안해도됨

 One call to hashCode could quickly identify the item as being not equal to 900 of the items, without having to use equals on any of those items.

 

 

hashcode 를 비교함으로써 hashcode 가 다른 900개랑은 애초에 비교안해도 되니까.,

 

비교대상개수를 줄여준다는 장점이 있지만, 그렇다고 hashcode 가 같다고 꼭 equal 하다는 보장은 없으니까. 

hashcode 같은 남은 적은 갯수의 애들만 비교하면 되는거임 ㅎㅎ