| Author |
HashMap
|
Will Myers
Ranch Hand
Joined: Aug 05, 2009
Posts: 287
|
|
Hi,
I have a question about HashMaps. If I have a HashMap and I insert an object that has a hashcode of say 10 will the underlying array of HashEntries have 10 elements even though the map contains just one object?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16811
|
|
will myers wrote:Hi,
I have a question about HashMaps. If I have a HashMap and I insert an object that has a hashcode of say 10 will the underlying array of HashEntries have 10 elements even though the map contains just one object?
No. The number of buckets is determine by a few conditions. The value of the hashcodes (of the elements) is not one of them.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: HashMap
|
|
|