Why Java’s HashMap Starts at 16, Not 10 or 12, and Why new HashMap(100) Still Resizes
Share

HashMap only uses power-of-two table sizes, so it can pick a bucket with one AND instead of a division. Ask for 10 buckets and you get 16…

 

<img src="https://cdn-images-1.medium.com/max/1280/1*zU-XgGVrJWeHsPSqPaAa8Q.png" title="Why Java’s HashMap Starts at 16, Not 10 or 12, and Why new HashMap(100) Still Resizes” /> HashMap only uses power-of-two table sizes, so it can pick a bucket with one AND instead of a division. Ask for 10 buckets and you get 16…Continue reading on Boot Camp Java » Read More Java on Medium 

#java

By ali

Leave a Reply