File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap

 
Will Myers
Ranch Hand
Posts: 372
Java jQuery Scala
  • 0
  • 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: 20823
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • 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