• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap

 
Will Myers
Ranch Hand
Posts: 387
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21497
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic