Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b66uwsWr9B1ouyrzUh
16 lines
533 B
Plaintext
16 lines
533 B
Plaintext
== equals() without hashCode() ==
|
|
a.equals(b) = true
|
|
a.hashCode() == b.hashCode() = false
|
|
HashSet size after adding a then b = 2
|
|
HashSet.contains(new equal key) = false
|
|
HashMap.get(equal key) = null
|
|
|
|
== with hashCode() ==
|
|
HashSet size after adding c then d = 1
|
|
HashSet.contains(new equal key) = true
|
|
|
|
== a legal but useless hashCode(): return 42 ==
|
|
keys = 2000
|
|
equals() calls for 2000 gets, constant hash = 2002999
|
|
equals() calls for 2000 gets, good hash = 2000
|